hi.
Pls give me the code to export data from datagrid or dataset into Excel in a simply way
regards
fazy
hi.
Pls give me the code to export data from datagrid or dataset into Excel in a simply way
regards
fazy
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
PeroPosted Mar 29, 2010, 3:43 AM
with GemBox.Spreadsheet C# Excel library you can easily export DataSet to Excel.
See code snippet below:
// Create new ExcelFile.
var ef = new ExcelFile();
// Imports all the tables from DataSet to new file.
foreach (DataTable dataTable in dataSet.Tables)
{
// Add new worksheet to the file.
var ws = ef.Worksheets.Add(dataTable.TableName);
// Insert the data from DataTable to the worksheet starting at cell "A1".
ws.InsertDataTable(dataTable, "A1", true);
}
// Save the file to XLS format.
ef.SaveXls("DataSet.xls");
Mahesh ChandPosted Apr 26, 2009, 11:14 PM
Mahesh ChandPosted Apr 26, 2009, 11:14 PM
Export to Excel is one of the most common functionality required in ASP.NET pages. Users can download the data from the DataGrid into an Excel spreadsheet for offline verification and/or computation.
This article describes how to Export an ASP.Net 2.0 GridView to Excel.
In this version of the article, we will include the handling the Hyperlink columns in the GridView export to Excel and also re-factor our original logic to use more general features of Reflection.
In this article we will take the contents of our GridView control and spill it into an Excel spreadsheet using this wrapper mechanism.