程序中去读EXCEL文档,以前一直参考《

程序又可以跑起来了...

 public static string ExcelConnectionString(string filePhysicalPath)
        {
            string connectionString = string.Empty;
            string fileExtension = filePhysicalPath.Substring(filePhysicalPath.LastIndexOf(".") + 1);
            switch (fileExtension)
            {
                case "xls":
                    connectionString = String.Format("Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};Extended Properties=\"Excel 8.0;HDR=YES;IMEX=1\"", filePhysicalPath);
                    break;
                case "xlsx":
                    connectionString = String.Format("Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0};Extended Properties=\"Excel 8.0;HDR=YES\"", filePhysicalPath);
                    break;
            }
            return connectionString;
        }
Source Code

相关文章:

  • 2021-03-27
  • 2021-07-20
  • 2021-09-01
  • 2021-07-08
  • 2021-08-19
  • 2021-04-09
  • 2021-10-25
  • 2021-10-25
猜你喜欢
  • 2022-02-22
  • 2021-12-29
  • 2022-01-21
  • 2021-11-05
  • 2021-12-22
  • 2021-12-20
相关资源
相似解决方案