Spire.XLS is a professional Excel API that enables developers to create, manage, manipulate, convert and print Excel worksheets. Get free and professional technical support for Spire.XLS for .NET, Java, Android, C++, Python.

Mon Mar 31, 2014 9:42 pm

I am getting the following exception when I execute SaveToStream method of the workbook, any ideas?

Thanks
Scott

System.ArgumentException was unhandled
Message=An item with the same key has already been added.
Source=mscorlib
StackTrace:
at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
at System.Collections.Generic.Dictionary`2.Add(TKey key, TValue value)
at Spire.Xls.Core.Spreadsheet.Collections.XlsWorkbookObjectsCollection.0(spr4940 A_0)
at Spire.Xls.Core.Spreadsheet.Collections.XlsWorksheetsCollection.1(IWorksheet A_0)
at Spire.Xls.Core.Spreadsheet.Collections.XlsWorksheetsCollection.Create()
at Spire.Xls.Workbook.0()
at Spire.Xls.Workbook.SaveToStream(Stream Stream, FileFormat fileFormat)
at XmlExcelBuilder.WorkbookBuilderSpire.createWorkbook() in c:\Users\sdubose\Documents\_My_Documents\VirtusCode\Utilities\XmlExcelBuilder\XmlExcelBuilder\WorkbookBuilderSpire.cs:line 35
at XmlExcelBuilder.ExcelBuilder.CreateWorkbook() in c:\Users\sdubose\Documents\_My_Documents\VirtusCode\Utilities\XmlExcelBuilder\XmlExcelBuilder\ExcelBuilder.cs:line 114
at XmlTester.Program.Main(String[] args) in c:\Users\sdubose\Documents\_My_Documents\VirtusCode\Utilities\XmlExcelBuilder\XmlTester\Program.cs:line 58
at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:

scott.dubose@virtusllc.com
 
Posts: 17
Joined: Wed Sep 18, 2013 8:49 pm

Mon Mar 31, 2014 9:43 pm

I've upgraded to the latest version, still getting the same error.

thanks
scott

scott.dubose@virtusllc.com
 
Posts: 17
Joined: Wed Sep 18, 2013 8:49 pm

Tue Apr 01, 2014 1:18 am

Hello,

Thanks for your feedback.
Could you please attach your document or code for testing? It would be helpful to reproduce the issue and work out the solution for you ASAP.
Thanks,
Gary
E-iceblue support team
User avatar

Gary.zhang
 
Posts: 1380
Joined: Thu Apr 04, 2013 1:30 am

Tue Apr 01, 2014 2:25 am

I can't it connects to our database and builds the workbook dynamically with data that comes back from stored procedure.

scott.dubose@virtusllc.com
 
Posts: 17
Joined: Wed Sep 18, 2013 8:49 pm

Tue Apr 01, 2014 2:26 am

Is there anything else I could attach that might help? debug output or something?

scott.dubose@virtusllc.com
 
Posts: 17
Joined: Wed Sep 18, 2013 8:49 pm

Tue Apr 01, 2014 3:48 am

OK, so I figured it out.

This works:
Code: Select all
Workbook wb = new Workbook();
wb.Worksheets.Clear();
wb.CreateEmptySheets(1);
Worksheet ws = wb.Worksheets.Add("TestSheet");


This does not work:
Code: Select all
Workbook wb = new Workbook();
wb.Worksheets.Clear();
Worksheet ws = wb.Worksheets.Add("TestSheet");


No offense but it doesn't make sense to me why we should have to call CreateEmptySheets AND Add after clearing the sheets in the workbook. Additionally the exception made little sense and did not help track down the error.

Regards
Scott

scott.dubose@virtusllc.com
 
Posts: 17
Joined: Wed Sep 18, 2013 8:49 pm

Tue Apr 01, 2014 3:52 am

The other problem with this approach is that I was hoping to this dynamically, where we don't know how many sheets there will be initially. I guess I will have to find a workaround for that unless you have some ideas?

Thanks
Scott

scott.dubose@virtusllc.com
 
Posts: 17
Joined: Wed Sep 18, 2013 8:49 pm

Tue Apr 01, 2014 7:58 am

Hello,

Thanks for the reply.
We have reproduced the issue you had, which has been transferred to our Dev team, once there are any update, we will let you know ASAP. Sorry for inconvenience.
If there are any questions, welcome to get it back to us.
Sincerely,
Gary
E-iceblue support team
User avatar

Gary.zhang
 
Posts: 1380
Joined: Thu Apr 04, 2013 1:30 am

Tue Apr 01, 2014 8:29 am

Hello,

The issue has been resolved, and next our testing team would test the hotfix, once it works fine, we will release the hotfix and let you know immediately.

Sincerely,
Gary
E-iceblue support team
User avatar

Gary.zhang
 
Posts: 1380
Joined: Thu Apr 04, 2013 1:30 am

Tue Apr 01, 2014 3:11 pm

Great, thank you!

--
Scott

scott.dubose@virtusllc.com
 
Posts: 17
Joined: Wed Sep 18, 2013 8:49 pm

Thu Apr 10, 2014 7:24 am

Hello,

There is an available hotfix for the issue you can download and test, which link is
http://www.e-iceblue.com/downloads/hot_ ... 7.3.10.zip

If there are any questions, welcome to get it back to us.

Sincerely,
Gary
E-iceblue support team
User avatar

Gary.zhang
 
Posts: 1380
Joined: Thu Apr 04, 2013 1:30 am

Wed Apr 16, 2014 8:57 am

Hello,

Now We have released the newest hotfix of Spire.Xls formally. You can download and test Spire.Xls7.3.12.

If there are any questions, welcome to get it back to us.

Thanks,
Gary
E-iceblue support team
User avatar

Gary.zhang
 
Posts: 1380
Joined: Thu Apr 04, 2013 1:30 am

Return to Spire.XLS