sConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;" +
"Data Source=" + fileName + ";" +
"Extended Properties='Excel 12.0;HDR=YES;'";
格式不兼容,导出为Office Open XML
sConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;" +
"Data Source=" + fileName + ";" +
"Extended Properties='Excel 12.0 Xml;HDR=YES;'";
Microsoft.ACE.OLEDB.12.0下载地址:http://www.microsoft.com/downloads/zh-cn/details.aspx?displaylang=zh-cn&FamilyID=7554f536-8c28-4598-9b72-ef94e038c891
03版:
sConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" +
"Data Source=" + fileName + ";" +
"Extended Properties=Excel 8.0;";
saveFileDialog.Filter = "Excel2003 files (*.xls)|*.xls|Excel2007 (*.xlsx)|*.xlsx|Excel2007二进制表 (*.xlsb)|*.xlsb"; ... if (fileName.EndsWith("xls")) { sConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=" + fileName + ";" + "Extended Properties=Excel 8.0;"; } else if (fileName.EndsWith("xlsx")) { sConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;" + "Data Source=" + fileName + ";" + "Extended Properties='Excel 12.0 Xml;HDR=YES;'"; } else if (fileName.EndsWith("xlsb")) { sConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;" + "Data Source=" + fileName + ";" + "Extended Properties='Excel 12.0;HDR=YES;'"; }
源自:http://www.cnblogs.com/TrueElement/archive/2012/02/17/2355923.html .csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, “Courier New”, courier, monospace; background-color: #ffffff; /*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em; } .csharpcode .lnum { color: #606060; }
发表回复
要发表评论,您必须先登录。