- Home
- Forum
- ASP.NET Core - EJ 2
- Iterative copying of Worksheets leads to error since version 31.2.3
Iterative copying of Worksheets leads to error since version 31.2.3
I am generating an Excel Workbook for Results if my application's calculations. Therefore I create the workbook, then I iteratively copy worksheets for groups of results. This works fine until version 31.2.2, I suddenly get an error after creating the third copy since version 31.2.3:
The code snippet of my method looks something like this:
foreach (var spreadsheetName in spreadsheetNames)
{
var worksheet = workbook.Worksheets.AddCopy(GetFirstOrCreateWorksheet(workbook));
worksheet.Name = spreadsheetName;
}
protected static IWorksheet GetFirstOrCreateWorksheet(IWorkbook workbook)
{
lock (LockObj)
{
return workbook.Worksheets.FirstOrDefault() ?? workbook.Worksheets.Create();
}
}
The occuring StackTrace shows the following exception:
System.ArgumentException
An item with the same key has already been added. Key: Syncfusion.XlsIO.Implementation.WorksheetImpl
System.ArgumentException: An item with the same key has already been added. Key: Syncfusion.XlsIO.Implementation.WorksheetImpl
at System.Collections.Generic.Dictionary`2.TryInsert(TKey key, TValue value, InsertionBehavior behavior)
at Syncfusion.XlsIO.Calculate.CalcEngine.RegisterGridAsSheet(String refName, ICalcData model, Int32 sheetFamilyID)
at Syncfusion.XlsIO.Implementation.WorksheetImpl.EnableSheetCalculations()
at Syncfusion.XlsIO.Implementation.Collections.WorksheetsCollection.Add(IWorksheet sheet)
at Syncfusion.XlsIO.Implementation.Collections.WorksheetsCollection.AddCopy(IWorksheet sheet, ExcelWorksheetCopyFlags flags, Boolean isLocal)
at Syncfusion.XlsIO.Implementation.Collections.WorksheetsCollection.AddCopy(IWorksheet sheet, ExcelWorksheetCopyFlags flags)
at Syncfusion.XlsIO.Implementation.Collections.WorksheetsCollection.AddCopy(IWorksheet sheet)
Hi Clemens,
The reported issue has been resolved, and the fix will be included in the upcoming weekly NuGet release scheduled for November 4, 2025.
Regards,
Karthika
Hi Karthinka,
thank you for the quick response and fix. I'm looking forward to it.
Regards,
Clemens
Hi Clemens,
We appreciate your patience.
We have included the fix to resolve the issue in our weekly NuGet release version 31.2.5. Kindly upgrade your Syncfusion packages to this new 31.2.5 version and let us know if the issue is resolved.
Regards,
Gowtham.
- 3 Replies
- 3 Participants
-
CT Clemens Tomsic
- Oct 30, 2025 12:08 PM UTC
- Nov 4, 2025 05:42 AM UTC