开发者

Read excel file and insert records in database in C#- Windows Azure

开发者 https://www.devze.com 2023-01-15 19:03 出处:网络
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.

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.

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 file:

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

FOR XLSX file:

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

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#?

A开发者_开发百科ny new ideas and suggestions are welcome.


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.

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

  • EPPlus for XLSX
  • NPOI for XLS


I am using OpenXMl SDK for excel processing. It works perfectly in cloud environment.


Since you mentioned you need to support .xls and .xlsx files, you could use a product like OfficeWriter which supports both file types in one library.

Disclaimer: I am one of the developers on OfficeWriter

0

精彩评论

暂无评论...
验证码 换一张
取 消