Hi,
I am trying to copy worksheets from one workbook to another. But AddWorksheet() & copyTo() methods throws "An item with the same key has already been added" exception while copying.
can anyone figure it out, what is the issue???
Here is the code:
```
var workbook = new XLWorkbook();
WriteStaticSheets(workbook);
public void WriteStaticSheets(XLWorkbook wb)
{
var workbookTemplate = new XLWorkbook("D:\\test.xlsx");
foreach(var ws in workbookTemplate.Worksheets)
{
wb.AddWorksheet(ws); // throws "An item with the same key has already been added"exception
ws.CopyTo(wb,ws.Name) //even this throws the same exception
}
}
```
I am trying to copy worksheets from one workbook to another. But AddWorksheet() & copyTo() methods throws "An item with the same key has already been added" exception while copying.
can anyone figure it out, what is the issue???
Here is the code:
```
var workbook = new XLWorkbook();
WriteStaticSheets(workbook);
public void WriteStaticSheets(XLWorkbook wb)
{
var workbookTemplate = new XLWorkbook("D:\\test.xlsx");
foreach(var ws in workbookTemplate.Worksheets)
{
wb.AddWorksheet(ws); // throws "An item with the same key has already been added"exception
ws.CopyTo(wb,ws.Name) //even this throws the same exception
}
}
```