Reading excel files from .NET
It is pretty easy to create excel files on the fly from .NET
Using the office automation stuff to read from excel files was always a pain. Here is a way to avoid that.
The connection string is just something like this:
String connString = @"Provider=Microsoft.Jet.OleDb.4.0;Data Source=" + Server.MapPath("Coupon Report Example.xls") + ";Extended Properties=Excel 8.0";
And you'd read from it with just a "SELECT * FROM [Sheet1$]"
If the sheet is named something else, you can just use the following to get the correct sheet name. http://www.codeproject.com/KB/aspnet/getsheetnames.aspx
Using the office automation stuff to read from excel files was always a pain. Here is a way to avoid that.
The connection string is just something like this:
String connString = @"Provider=Microsoft.Jet.OleDb.4.0;Data Source=" + Server.MapPath("Coupon Report Example.xls") + ";Extended Properties=Excel 8.0";
And you'd read from it with just a "SELECT * FROM [Sheet1$]"
If the sheet is named something else, you can just use the following to get the correct sheet name. http://www.codeproject.com/KB/aspnet/getsheetnames.aspx

0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home