Excel的连接字符串
Code
private string GetConnectionString(string filePath)
{
if (filePath.EndsWith(".xls"))
return string.Format("Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};"
+"Extended Properties='Excel 8.0;HDR=Yes;IMEX=2';", filePath);
if (filePath.EndsWith(".xlsx"))
return string.Format("Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0};"
+ "Extended Properties='Excel 12.0 Xml;HDR=YES';", filePath);
throw new Exception("wrong file type!");
}
posted @
2009-11-18 18:07
leixiaoling
阅读(
406)
评论()
编辑
收藏
举报