Sameep Baxi
Sameep Baxi

Reputation: 111

How to export DataSet values to Excel using EPPlus?

Currently I'm working with ExcelLibrary.dll The problem with ExcelLibrary is that it makes corrupt excel files if data is less or excel size is less than 6kB. So I am switching to EPPlus dll. Currently my code is:

        DataSet dsNewDataSet = new DataSet();
        string tempTbl = "SELECT * FROM EngineersDetail ORDER BY 3,1";
        SqlCommand commandOpen = new SqlCommand(tempTbl, conSql);
        SqlDataAdapter adpUpdRow = new SqlDataAdapter();
        adpUpdRow.SelectCommand = commandOpen;
        adpUpdRow.Fill(dsNewDataSet , "table");

        //Create Excel worksheet from the data sets
        ExcelLibrary.DataSetHelper.CreateWorkbook("C:/Engineer-wise Performance Report/Engineer-wise Performance Report.xls", dsNewDataSet );

This is a sample code. It selects data from the table EngineersDetail and fill in the DataSet dsNewDataSet, which then dumps data into an excel file. I later retrieve this excel file generated to send as an attachment in a mail.

Now I want to shift this code completely to EPPlus library code.

Upvotes: 0

Views: 698

Answers (0)

Related Questions