How to store data to Excel from DataSet without going cell-by-cell?
Posted
by
Jason Barnwell
on Stack Overflow
See other posts from Stack Overflow
or by Jason Barnwell
Published on 2009-05-27T21:29:57Z
Indexed on
2010/12/24
0:54 UTC
Read the original article
Hit count: 177
Duplicate of: What’s the simplest way to import a System.Data.DataSet into Excel?
Using c# under VS2008, we can create an excel app, workbook, and then worksheet fine by doing this:
Application excelApp = new Application();
Workbook excelWb = excelApp.Workbooks.Add(template);
Worksheet excelWs = (Worksheet)this.Application.ActiveSheet;
Then we can access each cell by "excelWs.Cells[i,j]" and write/save without problems. However with large numbers of rows/columns, we are expecting a loss in efficiency.
Is there a way to "data bind" from a DataSet object into the worksheet without using the cell-by-cell approach? Most of the methods we have seen at some point revert to the cell-by-cell approach. Thanks for any suggestions.
© Stack Overflow or respective owner