In order to read .xlsx files you need the drivers: http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=7554f536-8c28-4598-9b72-ef94e038c891
If you don't, you may get the error: "Could not find installable ISAM."
dir = new DirectoryInfo(System.Environment.CurrentDirectory);
xlsFiles = dir.GetFiles("*.xls", SearchOption.AllDirectories);
//loop thru all the text files
foreach (FileInfo xlsFile in xlsFiles)
{
DataSet dataSet1 = new DataSet();
OleDbConnection connection = new System.Data.OleDb.OleDbConnection();
OleDbDataAdapter dataAdapter1;
if (System.IO.Path.GetExtension(xlsFile.Name) == ".xlsx")
{
connection.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + xlsFile.FullName + ";Extended Properties='Excel 12.0;'";
}
else
{
connection.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + xlsFile.FullName + ";Extended Properties='Excel 8.0;'";
}
dataAdapter1 = new OleDbDataAdapter("select * from [Sheet1$]", connection);
dataAdapter1.Fill(dataSet1);
DataTable dt = dataSet1.Tables[0];
}
Thursday, April 24, 2008
c# read Excel 2007 .xlsx files
Friday, April 11, 2008
Monday, March 24, 2008
Friday, March 7, 2008
Jeremy Schneider's Blog: Hide form tag, but leave content
Jeremy Schneider's Blog: Hide form tag, but leave content: "The problem is that a common practice in ASP.NET is to have a tag 'high up' in the HTML, usually in the Master page. HTML doesn't allow overlapping tags, so my PayPal button won't work. Since the higher level is in the Master page, it makes removing it pretty messy. As far as I know, there's no built-in 'hide this tag"
Wednesday, March 5, 2008
Tuesday, March 4, 2008
ProperCase function in SSRS ( SQL Server Reporting Services)
=StrConv(Fields!Name.Value, vbProperCase)
found the answer here:
Any ProperCase function in SSRS report - TechNet Forums: "Any ProperCase function in SSRS report"
Subscribe to:
Posts (Atom)
