Hi,
We're using CodeNames to uniquely identify sheets within workbook no matter what is actual sheet name localized to.
So, we have a template file where we define CodeName directly in Excel (ALT+F11 -> Properties -> (Name)) and then use it. That all works good if we use 1 workbook only.
The problem is that we need to use 2 workbook templates and copy sheets from 1st one to 2nd one. As soon as we do that with code snippet below, all CodeNames from 1st workbook are gone and all copied sheets get CodeNames "Sheet1, Sheet2...". That doesn't work as our unique identifier got lost.
We tried it both with 5.5 and latest 7.0 version - same result.
Any ideas?
Thanks,
Martin
Code sample...
Workbook dataTemplate = new Workbook(@"C:\book1.xlsx");
Workbook textTemplate = new Workbook(@"C:\book2.xlsx");
if (dataTemplate!=null && textTemplate != null)
{
//use data template as base and copy all sheets from other ones
foreach (Worksheet worksheet in textTemplate.Worksheets)
{
//create new worksheet in datatemplate
Worksheet newWorksheet = dataTemplate.Worksheets.Add(worksheet.CodeName);
newWorksheet.Copy(newWorksheet);
}
}