471,317 Members | 1,500 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,317 software developers and data experts.

How convert Excel data into DataSet/DataTable?

Hi,

I need to open an Excel file from within my ASP.NET app and read data. I'm
guessing the most like format in ASP.NET would be a DataTable.

Regardles,, how do I get the data into my ASP.NET app from the Excel file?
I have made a reference to the Excel 11.0 object library, but am not sure
what code comes next.

Thanks,
Ron
Feb 14 '06 #1
2 22865
Ron,
As long as the data in the Sheet is tabular, you would probably be better
off just using an OleDb JET connection string directly to the Excel workbook
and reading in the data with ADO.NET

Excel with Interop is extremely messy on an IIS webserver.

There are a number of samples around, I just don't have one handy.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Ronald S. Cook" wrote:
Hi,

I need to open an Excel file from within my ASP.NET app and read data. I'm
guessing the most like format in ASP.NET would be a DataTable.

Regardles,, how do I get the data into my ASP.NET app from the Excel file?
I have made a reference to the Excel 11.0 object library, but am not sure
what code comes next.

Thanks,
Ron

Feb 14 '06 #2
Hello Ronald,

Use OLE DB Jet provider to access data stored in Excel.
connection string looks like: Provider=Microsoft.Jet.OLEDB.4.0;Data Source=myBook.xls;Extended
Properties="Excel 8.0;HDR=YES";

Then use

OleDbDataAdapter da;
da = new OleDbDataAdapter("SELECT * FROM [Sheet1$]", connectionString);

after that u Fill dataset and use it in your ASP.net page

I recomend to get data in XML format, coz it's easy to trasnsorm them in
suitable form for page using XSLT
RC> I need to open an Excel file from within my ASP.NET app and read
RC> data. I'm guessing the most like format in ASP.NET would be a
RC> DataTable.
RC>
RC> Regardles,, how do I get the data into my ASP.NET app from the Excel
RC> file? I have made a reference to the Excel 11.0 object library, but
RC> am not sure what code comes next.
RC>
RC> Thanks,
RC> Ron
---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche
Feb 14 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

9 posts views Thread by B. Salmon | last post: by
2 posts views Thread by karups | last post: by
4 posts views Thread by =?Utf-8?B?RnJhbmsgVXJheQ==?= | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.