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