对于ExcelWriter.Worksheets上的每个循环,需要花费过长的时间来处理 - 任何解决方法?

时间:2013-12-18 17:01:18

标签: vb.net performance officewriter

我遇到的问题是 For Each ws In xlWorkbook_.Worksheets 声明过长时间处理。只有7个工作表,处理一个语句需要23秒。我使用的模板文件是.xlsx,我使用ExcelWriter编写的所有以前的报告都使用了.xls模板文件。这是我能看到的唯一真正的区别。使用.xls模板使用相同的方法,语句将处理亚秒级。我使用的是最新版本的OfficeWriter(8.6.1)和2010版的Excel。

是否还有其他人遇到此问题,或者是否有其他方法可以循环显示工作簿中每张工作表更快的表单?

我使用的代码看起来很像:

Dim xlApp_ As ExcelApplication
Dim xlWorkbook_ As Workbook
Dim xlTemplate_ As ExcelTemplate
Dim ws As Worksheet

....
Code to initially populate the data using the ExcelTemplate
  - copies single sheet to x number of additional sheets depending on how many are needed
  - renames the datamarkers on the sheets that were added and binds the datasets to the datamarkers
  - processes the template to populate all of the sheets with data
....

xlWorkbook_ = xlApp_.Open(xlTemplate_)

For Each ws In xlWorkbook_.Worksheets
  ....
  code to change worksheet name and format various parts of the worksheet
  ....
Next

0 个答案:

没有答案