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.

Wed Mar 20, 2019 7:31 am

Hello,

Version: 9.3.4

I am merging multiple Workbooks into a single one using the Workbook.Worksheets.AddCopy method to add all the worksheets.
So far it works as intended.

The problem occurs if one of the sheets contains a chart => The AddCopy method throws a NullReferenceException with the following StackTrace
Code: Select all
at spr៝.ᜀ(spr។ A_0)
   at Spire.Xls.Core.Spreadsheet.XlsWorksheetBase.Clone(Object parent, Boolean cloneShapes)
   at Spire.Xls.Core.Spreadsheet.XlsWorksheetBase.Clone(Object parent)
   at Spire.Xls.Core.Spreadsheet.Charts.XlsChart.Clone(Dictionary`2 hashNewNames, Object parent, Dictionary`2 dicFontIndexes)
   at Spire.Xls.Core.Spreadsheet.Shapes.XlsChartShape..ctor(sprឌ A_0, Object A_1, XlsChartShape A_2, Dictionary`2 A_3, Dictionary`2 A_4)
   at Spire.Xls.Core.Spreadsheet.Shapes.XlsChartShape.Clone(Object parent, Dictionary`2 hashNewNames, Dictionary`2 dicFontIndexes, Boolean addToCollections)
   at Spire.Xls.Core.Spreadsheet.Collections.ShapeCollectionBase.AddCopy(XlsShape sourceXlsShape, Dictionary`2 hashNewNames, Dictionary`2 dicFontIndexes)
   at Spire.Xls.Core.Spreadsheet.XlsWorksheetBase.CopyShapes(XlsWorksheetBase sourceSheet, Dictionary`2 hashNewNames, Dictionary`2 dicFontIndexes)
   at Spire.Xls.Core.Spreadsheet.XlsWorksheetBase.ᜀ(XlsWorksheetBase A_0, Dictionary`2 A_1, Dictionary`2 A_2, Dictionary`2 A_3, WorksheetCopyType A_4, Dictionary`2 A_5)
   at Spire.Xls.Core.Spreadsheet.XlsWorksheet.CopyFrom(XlsWorksheet worksheet, Dictionary`2 hashStyleNames, Dictionary`2 hashWorksheetNames, Dictionary`2 dicFontIndexes, WorksheetCopyType flags, Dictionary`2 hashExtFormatIndexes, Dictionary`2 hashNameIndexes, Dictionary`2 hashExternSheets)
   at Spire.Xls.Core.Spreadsheet.Collections.XlsWorksheetsCollection.ᜀ(IWorksheet A_0, WorksheetCopyType A_1, Boolean A_2)
   at Spire.Xls.Core.Spreadsheet.Collections.XlsWorksheetsCollection.AddCopy(IWorksheet sheet, WorksheetCopyType flags)
   at Spire.Xls.Core.Spreadsheet.Collections.XlsWorksheetsCollection.AddCopy(IWorksheet sheet)
   at Spire.Xls.Collections.WorksheetsCollection.AddCopy(Worksheet sheet)



I tried different things but I am not able to fix this problem. The same worksheets are merged without problem if I remove the chart.
But with the chart I always get the same error.

Is there a way how I could bypass this problem?

Thank you in advance.

Cheers
Karl

karl.pircher@recla.it
 
Posts: 15
Joined: Mon Mar 14, 2016 2:16 pm

Wed Mar 20, 2019 8:22 am

Hello,

Thanks for your inquiry.
I tested your scenario with the latest Spire.XLS Pack(Hotfix) Version:9.3.4, and didn't encounter the exception when executing AddCopy method, however, my generated excel hinted an information that there was a problem with content, also the chart was not copied successfully. I have logged the issue in our bug tracking system. If it is fixed or there is any update, we will inform you. Besides, could you please provide your testing Excel file which has a chart, so that we can fix your issue better accordingly to file. You could send it to us via email (support@e-iceblue.com).

Sincerely,
Nina
E-iceblue support team
User avatar

Nina.Tang
 
Posts: 1195
Joined: Tue Sep 27, 2016 1:06 am

Mon Apr 15, 2019 9:57 am

Hello,

I'm delighted to inform you that the issue you reported has been resolved, welcome to download the hotfix from the following link.
Our website link: Spire.XLS Pack(Hotfix) Version:9.4.6
NuGet link: https://www.nuget.org/packages/Spire.XLS

Sincerely,
Nina
E-iceblue support team
User avatar

Nina.Tang
 
Posts: 1195
Joined: Tue Sep 27, 2016 1:06 am

Return to Spire.XLS