阅读excel文件并在C# - Windows Azure中的数据库中插入记录 [英] Read excel file and insert records in database in C#- Windows Azure

查看:102
本文介绍了阅读excel文件并在C# - Windows Azure中的数据库中插入记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序的要求是浏览一个excel文件,上传文件,从excel文件中读取每一行并插入数据库。

The requirements for my application is to browse for an excel file, Upload the file , read each row from the excel file and insert into the database.

我是在Windows Azure中构建此应用程序。
在此之前,我已成功使用 OleDbDataAdapter 将excel文件中的数据读入数据集

I am building this application in Windows Azure. Prior to this I have successfully used OleDbDataAdapter to read the data from the excel file into the dataset.

我使用的连接字符串是:

The connection strings I used are:

FOR XLS文件:

FOR XLS file:

connString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strNewPath & ";Extended Properties=""Excel 8.0;HDR=Yes;IMEX=2"""

FOR XLSX文件:

FOR XLSX file:

connString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & strNewPath & ";Extended Properties=""Excel 12.0;HDR=Yes;IMEX=2"""

以下提供商 Microsoft.Jet.OLEDB.4.0 & Microsoft.ACE.OLEDB.12.0 在Windows Azure中可以使用?
这个方法也可以在Cloud中工作,这是在c#中访问Excel文件的最好方式吗?

Will the following providers Microsoft.Jet.OLEDB.4.0 & Microsoft.ACE.OLEDB.12.0 be avaialable in Windows Azure? Will approach also work in Cloud as well and is this the best way to access Excel files in c#?

欢迎任何新的想法和建议。

Any new ideas and suggestions are welcome.

推荐答案

不,默认情况下,OLE提供者将不能在工作角色下使用。可能有可能在不同的VM设置中使用它们。

No, OLE providers will not be available under the Worker Role by default. It might be possible to have them later in a different VM setup though.

目前,您基本上仅限于仅使用.NET的选项:

For the time being you are basically restricted to .NET-only options:

  • EPPlus for XLSX
  • NPOI for XLS

这篇关于阅读excel文件并在C# - Windows Azure中的数据库中插入记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆