示例#1
0
        public void CreateReport(IHistoryManager historyManager, ReportOptions reportOptions)
        {
            var dataTable = historyManager.ToDataTable();

            using (var workBook = new WorkBook())
            {
                //add new sheet where the report will be written
                workBook.insertSheets(SheetIndex.Report, 1);

                workBook.ImportDataTable(dataTable, true, 0, 0, dataTable.Rows.Count, dataTable.Columns.Count);

                for (int colIndex = 0; colIndex < dataTable.Columns.Count; colIndex++)
                {
                    workBook.setColWidthAutoSize(colIndex, true);
                }

                workBook.setSheetName(SheetIndex.Report, reportOptions.SheetName);

                ExportToExcelTask.SaveWorkbook(reportOptions.ReportFullPath, workBook);

                if (reportOptions.OpenReport)
                {
                    FileHelper.TryOpenFile(reportOptions.ReportFullPath);
                }
            }
        }
 public void ExportToExcel(IEnumerable <DataTable> dataTables, string fileName, bool launchExcel)
 {
     ExportToExcelTask.ExportDataTablesToExcel(dataTables, fileName, launchExcel);
 }
示例#3
0
 public Task ExportToExcelAsync(IEnumerable <DataTable> dataTables, string fileName, bool launchExcel = true) =>
 Task.Run(() => ExportToExcelTask.ExportDataTablesToExcel(dataTables, fileName, launchExcel));
示例#4
0
 public void ExportDataTableToExcel(DataTable dataTable, string fileName, bool openExcel)
 {
     ExportToExcelTask.ExportDataTableToExcel(dataTable, fileName, openExcel);
 }