Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
20
Excel worksheet to System.Data.DataTable
posted

Hi,

I have a scenario, where Excel files are uploaded and saved on the server and they need to be parsed by the server side process and loaded into SQL server database tables. Ideally, I would like to use something like this:

Workbook w = Workbook.Load(filePath);

Worksheet ws = w.Worksheets["MyWorksheetName"];

System.Data.DataTable tbl = ws.AsDataTable();  //Desired functionality

After having DataTable instance I would use SqlBulkCopy to load data to the database tables.

Is there any way of exporting data within worksheet as table without iterating through each row and cell?

I have a solution utilizing Microsof ACE (Microsoft.ACE.OLEDB.12.0) driver, but due to policies I cannot install it on the server. 

Thanks, I will appreciate your response.

Jerzy