Worksheets Gone After Save() Method Call


I just got the latest hotfix and was happy to see the ability to copy worksheets has been added - thank you!

I have, however, run into a problem.

Here is the general idea of what I am doing:

* I am generating individual reports one at a time while looping through a datasource

* The individual reports (Excel objects) get saved

* As I am creating the individual reports, I copy the worksheets from each individual report into a "batch" report (Excel object)

* I now notice, that, after calling:

myExcel.Save(filename, FileFormatType.Default)

That the Worksheets seem to be gone at this point? I have verified this by seeing that myExcel.Worksheets.Count == 1 when it was 2, and the Sheet names are all gone.

Am I improperly calling save() in this instance?

Thanks in advance for the help.


Yes. After you call Excel.Save method, Excel object is re-initialized. If you want to preserved it, you can use Excel.Copy method to make a copy.

Dim Excel1 as Excel = new Excel()
’ Do something

Dim Excel2 as Excel = new Excel()


'Now you can discard Excel1 and use Excel2 for other purpose
Excel1 = nothing


Laurence -

Thank you for that information. That did just what I needed it to.

I have noticed that during the Copy certain page formatting (like fixing certain rows to act as a “header” using the “Rows to repeat header” in Page Setup, etc) are not copied. Additionally, any images are not copied as well.

Is this known about the Copy feature?

Thanks again for your assistance.


I will check the Page Setup issue. However, the images in designer file are not copied in Worksheet.Copy method. It's too complex to copy those drawing objects in a single worksheet. Please check the API reference at


Laurence -

I understand the copying of images won’t be happening… any update on the page formatting not being copied over?


You will get update on page formatting in next week.


Laurence -

I got the latest hotfix and it fixed the problem of the Worksheet’s page formatting not copying over.

However, I am now noticing that in the Worksheet that I copy TO, cell borders seem to be set (somewhat randomly) on things that do not have borders on the place it was copied from.

Anything that has a border in the source sheet does have a border when its copied, it just seems that additional cells have borders in the resulting sheet that didn’t in the source.

Any ideas?


Please send the source file and related code to I will check it right now.


Laurence -

I tried sending an email to that address both last night and it was returned. I tried again this morning with the same result.

Any ideas?


Please send it to


Laurence -

FYI - On Friday I sent the Excel files to the email address provided in your last post.

Thanks again for the help!


Hi Matthew,

I got it. Now I am investigating it. Thanks for your patience.


Hi Matthew,

I find what caused this problem and have to do a little bit work. You will get fix for this issue next week.