views:

3336

answers:

3

Hi!

I need a way to read a Excel file from a stream. It doesn't seem to work with the ADO.NET way of doing things.

The scenario is that a user uploads a file through a FileUpload and i need to read some values from the file and import to a database.

For several reasons i CAN'T save the file to disk, and there is no reason to do so eighter.

So, anyone know of a way to read a excel file from a FileUpload stream?

A: 

Infragistics has an excel component that can read an excel file from a stream.

I'm using it in a project here and it works well.

Also the open source myXls component could easily be modified to support this. The XlsDocument contstructor only supports loading from a file given by a file name, but it works by creating a FileStream and then reading the Stream, so changing it to support loading from streams should be trivial.

Edit: I see that you found a solution but I just wanted to note that I updated the source code for the component so that it now can read an excel file directly from a stream. :-)

Rune Grimstad
+3  A: 

It seems i found a soultion to the problem myself.

http://www.codeplex.com/ExcelDataReader

This library seems to work nicely and it takes a stream to read the excel file.

ExcelDataReader reader = new ExcelDataReader(ExcelFileUpload.PostedFile.InputStream);
Kristian
A: 

SpreadsheetGear can do it:

SpreadsheetGear.IWorkbook workbook = SpreadsheetGear.Factory.GetWorkbookSet().Workbooks.OpenFromStream(stream);

You can try it for yourself with the free evaluation.

Disclaimer: I own SpreadsheetGear LLC

Joe Erickson