I am exporting massive amounts of data to an excel sheet. We are running into performance issues with trying to properly format the data for a report in Active Reports. I set up some basic print outs to determine what sections of code are taking the longest parts of time. I broke apart the cell formatting with setting the cells value.
Private Sub SetSheetFormat(intRow As Integer, dDSheet As DDSheet)
Dim startRow As Integer = 6
Dim cells As Cells.DDCells = dDSheet.Cells(dDSheet.Cell(startRow, 0), dDSheet.Cell(intRow, 45))
cells.FontSize = 8
dDSheet.Cell(intRow, 47).SetValue((Date.Now - start).ToString())
cells = dDSheet.Cells(dDSheet.Cell(startRow, ReportColumns.FirmDemands), dDSheet.Cell(intRow, ReportColumns.SI_SSDollars))
cells.Alignment = Style.HorzAlignments.Right
dDSheet.Cell(intRow, 48).SetValue((Date.Now - start).ToString())
cells = dDSheet.Cells(dDSheet.Cell(startRow, ReportColumns.FirmDemands), dDSheet.Cell(intRow, ReportColumns.NetFcst))
cells.FillColor = Color.FromArgb(255, 224, 192) 'light orange
dDSheet.Cell(intRow, 49).SetValue((Date.Now - start).ToString())
cells = dDSheet.Cells(dDSheet.Cell(startRow, ReportColumns.FirmTfrsOut), dDSheet.Cell(intRow, ReportColumns.KitComptUsage))
cells.FillColor = Color.FromArgb(255, 255, 192) 'light yellow
cells = dDSheet.Cells(dDSheet.Cell(startRow, ReportColumns.FirmProd), dDSheet.Cell(intRow, ReportColumns.PlannedTfrsIn))
cells.FillColor = Color.FromArgb(&HC0FFC0) 'light green
cells = dDSheet.Cells(dDSheet.Cell(startRow, ReportColumns.TotalReceipts), dDSheet.Cell(intRow, ReportColumns.TotalReceipts))
cells.FillColor = Color.FromArgb(&H80FF80) 'dark green
dDSheet.Cell(intRow, 50).SetValue((Date.Now - start).ToString())
With approximately 7000 rows in the spreadsheet. The time it took to write the data before it entered this method was 6 seconds. Setting the fontsize to 8 took 50 seconds alone. Is there a better way of doing this? I thought applying it to multiple cells at once would do more of transactional thing and be more efficient but it is not.
UPDATE: Please note that we are not generating this workbook from a PageReport or PageDocument. We are writing what we want directly to a Workbook.
答案 0 :(得分:0)
您正在使用SpreadBuilder将数据导出到Excel文件。在SpreadBuilder中,数据在Excel文件中逐个单元格导出,并且由于您有大量数据,因此导出数据花费了大量时间。然后,为了修改数据,它必须遍历每个单元格,然后格式化单元格,这样花费50秒。基本上,问题是由于数据量非常大而导致SpreadBuilder逐个单元地用于Excel导出。
更好的方法是,您可以在生成报告时或在导出之前对报告的字段进行修改,然后使用Export filters / Rendering Extensions导出。这是在此方案中优化Excel导出的唯一方法。