Thursday, March 13, 2014

Import Excel to SQL DB quiet simple....


As POC I have done a simple project to Import Excel data to SQL Table.

It 's quiet simple & easy. I have tried to Import Excel in 3 different ways to identify which one is most effective way.

I have came across these scenarios:
  • Using .Net OleDbCommand
  • Using SSIS
  • Using OpenXml
  • Using XmlTextWriter
Actually, effectiveness depends on the Data Load. For the Bulk & the complex data I am recommending you to go with SSIS.

Let's brief one by one.

Using .Net OleDbCommand

It's just save the uploaded file & read from the FTP, then map with the columns in both Excel & DB, finally copy data in to the database.

Using SSIS

For SSIS code end it looks easy, But we have to develop and SSIS package as the requirement. If we have the deployed SSIS package, we need to just trigger the function only. 

Developing SSIS is easy & fun, But somethings I am stuck with the configurations. Only the important figures I have attached.

By defining variable we can make the package, dynamic for Excel & database.

Using OpenXml

It is similar to OleDbCommand but OpenXML is better than COM Interop in .Net. Though you don't see any significant performance in OpenXML than COM, it is easy to code. Easier to maintain. Considering the large amounts of data you should read, take a look at below link for optimizing.

Using XmlTextWriter

Here data read from an XML file content and write the same content to an Excel file. Using an XmlReader for read the XML file to the Dataset . Loop through the Dataset and add the content to the Excel file, that become slower for the big amount of data.


I think this will be helpful for you..

B' happy always....... :)

No comments:

Post a Comment