问题描述
嗨大家好
我目前通过vb.net在excel中生成报告。
目前我正在使用的过程是从数据库中获取数据并将返回的数据存储到数据表中然后循环遍历数据表中的每条记录并添加每列在excel表的每条记录中
问题是当报表包含大量数据时,例如12万+记录报告需要相当长的时间来生成是否有更好的方法来加快性能
我尝试过:
dim dt作为新数据表(车辆)
dt = GetVehicledata()
每个dtrow中的
dt.rows
xSheet.Cells(RowDataStart,4).value = DtRow(REGNUM)。ToString
xSheet.Cells(RowDataStart,5).value = DtRow(DRIVER)。ToString
xSheet.Cells(RowDataStart,6).value = DtRow(STARTDATE)。ToString
xSheet.Cells(RowDataStart,7).value = DtRow(STARTTIME)。ToString
xSheet.Cells(RowDataStart,8).value = DtRow(ENDTIME ).ToString
next
Hi Guys
I am currently generating reports in excel through vb.net.
Currently the process that i am using is i get the data from the database and store the data returned into a datatable
i then loop through each record in the datatable and add each column in each record to the excel sheet
Problem is when the report contains large data e.g. 120 000 + records reports take rather long to generate is there a better way to speed up the performance
What I have tried:
dim dt as new datatable("Vehicles")
dt = GetVehicledata()
for each dtrow in dt.rows
xSheet.Cells(RowDataStart, 4).value = DtRow("REGNUM").ToString
xSheet.Cells(RowDataStart, 5).value = DtRow("DRIVER").ToString
xSheet.Cells(RowDataStart, 6).value = DtRow("STARTDATE").ToString
xSheet.Cells(RowDataStart, 7).value = DtRow("STARTTIME").ToString
xSheet.Cells(RowDataStart, 8).value = DtRow("ENDTIME").ToString
next
这篇关于如何提高excel生成的性能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!