I have 3 sepereate datatables in C# I want to export to a single Excel Workbook, each on different sheets. Is there an easy way to do this? I thought about adding the tables to a single dataset, but that didn't seem possible. I wrote a method that can convert a single dataTable into a csv file, but that doesn't work for multiple tables. Thanks!
I used the first link and it's creating an Excel, but then it crashes for two reasons: The way it resized the columns didn't work:
// Resize the columns
oRange = oSheet.get_Range(oSheet.Cells[1, 1],
oSheet.Cells[rowCount, dt.Columns.Count]);
And I added this to make a second sheet and it didn't work:
Excel.Worksheet sheet2;
oWB.Sheets.Add(name[1], Type.Missing, Type.Missing, Type.Missing);
sheet2 = (Excel.Worksheet)oWB.Sheets[1];
I can figure out how to fix my code and add another sheet, but does anyone know why the resize columns isn't working?