Hi Melba,
one special thing I see is that in the beginning, the workbook contains the range only once because the sheet exists only once. But during runtime, I am generating the other sheets by creating copies from the existing sheet. Here is the function that creates the copy:
public IWorksheet ExportXlsIOCopyTemplateSheet(IWorkbook workbook, string templateSheet) //, string insertAfterName) // Excel._Worksheet insertAfter)
{
IWorksheet wsTemplate = null;
IWorksheet wsNew = null;
try
{
wsTemplate = workbook.Worksheets[templateSheet];
if (wsTemplate != null)
{
wsNew = workbook.Worksheets.AddCopyBefore(wsTemplate, wsTemplate);
}
wsNew.Select(); // Missing.Value);
}
catch (Exception ex)
{
Tracing.TraceException(ex);
}
return wsNew;
}
... and here is an exemple function call:
winbase.ExportXlsIOCopyTemplateSheet(_XlsIOWorkbook, "General"); // _XlsIOWorkbook contains the template sheet, the copy should be inserted right before the template sheet
This function I use to address the ranges:
protected IRange ExportXlsIOGetRange(IWorksheet worksheet, string reference)
{
IRange range = null;
try
{
range = worksheet.Range[reference];
}
catch { }
return range;
}
.. and this is an example function call:
IRange range = ExportXlsIOGetRange(worksheet, "_Title_"); // worksheet alsways is a newly generated copy of the template sheet
Attached I send you the XLT-file which we are using as template.
Thanks for your help and best regards
Christian
DeltaMaster.zip