I am using your Cells product and creating a workbook from a template we have created. I have 4 sheets which are populated with data and then I have one sheet which I use Addcopy to dynamically create many new sheets. If I do not create new sheets I have no problem. If I create a new sheet then I cannot open the xls file without getting file errors. her is the code that executes to add new sheets. Any ideas?
wb.Worksheets.AddCopy("Facility")
wb.Worksheets.ActiveSheetIndex = x + 4
ws = wb.Worksheets.Item(x + 4)
If Len(ProcessLevel(x).ToString & " - " & ProcessLevelDisplayName(x).ToString) > 31 Then
Could you try the attached version. I tested and tried the following sample code using a template file and it works fine. I opened the output file into MS Excel and it opened fine.
[C#]
Workbook wb = new Workbook(); wb.Open("d:\\test\\Template_book .xls"); for (int i = 0;i<5;i++) { wb.Worksheets.AddCopy("Module_Detail"); } wb.Save("d:\\test\\TestNewAddCopy1.xls")
[VB]
Dim wb As Workbook = New Workbook() wb.Open("d:\test\Template_book .xls") Dim i As Integer
For i = 0 To 4 wb.Worksheets.AddCopy("Module_Detail") Next wb.Save("d:\test\TestNewAddCopy1.xls")
If you still find the issue, kindly post your template file here.
This is the file. The sheet I copy is the one named “Facility”. When I open the xls file I get a message that file is damaged and it does a recover. If I save the file and reopen everything looks fine. Could it be that I am running the trial version? I am using VB in VS2005 with a Web Project. Thanks for the help.
Well, I have no problem at all. I utilized your template file and implement AddCopy() method, the output file (attached) is fine. Please make sure that your are using the lastest fix which I posted in my previous post in this thread.
Following is my sample code and attached the output file.
Workbook wb = new Workbook(); wb.Open("d:\\test\\ScoreCard_Template.xls"); for (int i = 0;i<5;i++) { wb.Worksheets.AddCopy("Facility"); } wb.Save("d:\\test\\Test_AddCopy_2.xls");
If you still find the problem, please create a sample console app with your template file, zip it and post it here. We will check it soon.
I tried it again and it worked but I lost some of the formatting with your new dll. I received my license file this morning and I uninstalled cells and reinstalled the orginal version and everything is now working fine. I guess the fact that it was the trial version was the culprit. Thank You for your help.