DataSet ds = new DataSet(); System.Data.DataTable table = new System.Data.DataTable(); table = ds.Tables.Add(); string[] s1 = { "name", "age" }; string[] s2 = { "John", "30" }; table.Columns.Add("Attributes"); table.Columns.Add("Values"); for (int i = 0; i < 2; ++i) { table.Rows.Add(s1[i], s2[i]); }
// 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");
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)