This project has moved. For the latest updates, please go here.

How to read a web based file

May 2, 2011 at 9:54 PM


This might be simple...but not to me, apparently ;-)

I have an xlsx file on the web server and I would like to read from it. Something tells me I need to create a Stream from it somehow. How do I get to that? I tried using Stream, but without much luck. 

Input will be greatly appreciated!



May 2, 2011 at 10:37 PM

Open your file as a MemoryStream and pass to ExcelPackage constructor. I did with fileupload and works like a charm.

May 2, 2011 at 11:15 PM

Great. But (out of forum, I know) - how do you 'serve' the file to the MemoryStream - as byte[]?

May 3, 2011 at 8:51 PM

Use a filestream or a memorystream like this...

var file = File.ReadAllBytes(yourFileName)
MemoryStream ms = new MemoryStream(file);