Hi,
I’m using a template file to set up product specific comprehensive reports. During the generation process I copy worksheets from the template into the final report file. Thereby I reuse template worksheets as much as possible. After the upgrade from Aspose 5.x to 7.3 everything worked fine. Last week I changed the size of the plotting area within one template worksheet. Since this point of time, I’m unable to reuse these worksheets. The first usage is OK, but the second usage results in an exception.
Can you please check this? Please find attached also the sample source code, the sample excel file (template) as well as the error message.
Thanks in advance
Code:
private static void Kopieren()
{
string path = System.Windows.Forms.Application.StartupPath;
License l = new License();
l.SetLicense("Aspose.Total.lic");
//Vorlage
Workbook template = new Workbook(Path.Combine(path, "example.xls"));
//Erzeugen einer neuen Arbeitsmappe
Workbook wb = new Workbook();
KopiereTemplates(template, wb, "Chart", "Chart 1");
KopiereTemplates(template, wb, "Chart", "Chart 2"); //Without this line, the code can be executed without en error message
KopiereTemplates(template, wb, "Data", "Data 2");
wb.Save(Path.Combine(path, "test.xlsx"), SaveFormat.Xlsx);
}
public static void KopiereTemplates(Workbook wb_template, Workbook wb, string template, string name)
{
if (template.Length > 0)
{
if (wb_template != null)
{
Worksheet ws = wb_template.Worksheets[template];
if (ws != null)
{
int index = wb.Worksheets.Add();
wb.Worksheets[index].Copy(ws);
wb.Worksheets[index].IsVisible = true;
wb.Worksheets[index].Name = name;
}
}
}
}