hi
How to run over DataSet and insert into Excel (not .csv file) ?
i work on C#, Visual-studio 2008, Excel 2007
thank's in advance
hi
How to run over DataSet and insert into Excel (not .csv file) ?
i work on C#, Visual-studio 2008, Excel 2007
thank's in advance
Here is a useful article: Reading and Writing Excel Spreadsheets Using ADO.NET C# DbProviderFactory
You need to look into the Office Interop Libraries, see this example take from here.
Microsoft.Office.Interop.Excel.Application xl =
new Microsoft.Office.Interop.Excel.Application();
xla.Visible = true;
Workbook wb = xla.Workbooks.Add(XlSheetType.xlWorksheet);
Worksheet ws = (Worksheet)xla.ActiveSheet;
int i = 1;
int j = 1;
foreach (ListViewItem comp in lvwResults.Items)
{
ws.Cells[i, j] = comp.Text.ToString();
//MessageBox.Show(comp.Text.ToString());
foreach (ListViewItem.ListViewSubItem drv in comp.SubItems)
{
ws.Cells[i, j] = drv.Text.ToString();
j++;
}
j = ;1;
i++;
}
This of course requrires that you have Excel installed on the machine running the program.