Save the results of the command to a package

Apr 28, 2012 at 10:02 AM

Hi, how can I save the results of the command to a package?

 

 SqlDataAdapter da = new SqlDataAdapter(command);
                DataSet ds = new DataSet();
                da.Fill(ds);

                FileInfo newFile = new FileInfo(@"C:\Test.xlsx");

                OfficeOpenXml.ExcelPackage package = new ExcelPackage(newFile);

                ExcelWorksheet ws = package.Workbook.Worksheets.Add("Content");
   

Coordinator
May 2, 2012 at 6:17 PM

Hi,

Use the ws.Cells["A1"].LoadFromDataTable method (to start loading in cell A1), using the datatable in your dataset.

Jan