The problem that I am experiencing is that the For Each ws In xlWorkbook_.Worksheets statement is taking excessively long to process. With only 7 worksheets it is taking 23 seconds to process the one statement. The template file that I am using is an .xlsx and all previous reports that I have written using ExcelWriter have used a .xls template file. That is the only real difference that I can see. Using the .xls templates with the same approach the statement will process sub-second. I am using the latest version of OfficeWriter (8.6.1) and 2010 version of Excel.
Has anyone else had this issue or have an alternate way of looping through each sheet in the workbook that would perform significantly faster?
The code I am using looks effectively like this:
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