Worksheets.AddCopy gives "Value cannot be null"

When I try to copy a worksheet from one workbook to a new workbook (new file) I get the following:

Dim newFile As New GemBox.Spreadsheet.ExcelFile
newFile.Worksheets.AddCopy(mySheet.Name, mySheet)

ERROR: Value cannot be null
Parameter name: collection

(mySheet is a worksheet from another workbook.)

This exact same code worked in Gembox v41.3.30.1183…now Im using v47.0.1363

Am I doing something wrong

Hi Ton,

I’m afraid the issue is specific to your Excel file, can you please send it to us?

Also, please specify what is the name of your mySheet.

Regards,
Mario

Hi Mario,

I don’t want to put the file on the public forum because it’s from a client…can I send it in a private message to you?

BR, Ton.

You can send it to us via email or send it to “Technical Support”, see our contact page.

The problem occurred because of a specific chart with a multi level axis.

Anyway, the issue is now resolved with this bugfix:
https://www.gemboxsoftware.com/spreadsheet/nightlybuilds/GBS47v1375.zip

Or this NuGet package:
Install-Package GemBox.Spreadsheet -Version 47.0.1375-hotfix

Regards,
Mario

I found the similar issue in version 49.03.1301
System.NullReferenceException: ‘Object reference not set to an instance of an object.’
Stack Trace

   at GemBox.Spreadsheet.Charts.ChartDataLabelsData.Clone()
   at GemBox.Spreadsheet.Charts.ChartSeries.Import(ChartSeries source)
   at GemBox.Spreadsheet.Charts.ExcelChart.Import(ExcelChart source)
   at GemBox.Spreadsheet.Charts.ColumnChart.Import(ExcelChart source)
   at GemBox.Spreadsheet.Charts.ExcelChart.Clone()
   at GemBox.Spreadsheet.ExcelDrawingCollection`1.AddCopy(T item)
   at GemBox.Spreadsheet.ExcelDrawingCollection`1..ctor(ExcelWorksheet worksheet, ExcelDrawingCollection`1 source)
   at GemBox.Spreadsheet.ExcelWorksheet..ctor(String name, ExcelWorksheetCollection parent, ExcelWorksheet sourceWorksheet)
   at GemBox.Spreadsheet.ExcelWorksheetCollection.InsertCopyInternal(String destinationWorksheetName, Int32 position, ExcelWorksheet sourceWorksheet)

Hi Oleg,

Please send us your Excel file so that we can reproduce this issue and investigate it.

Regards,
Mario

Sure
uploaded test file here
test

Hi,

Please try again with this bugfix version:
https://www.gemboxsoftware.com/spreadsheet/nightlybuilds/GBS49v1324.zip

Or this NuGet package:
Install-Package GemBox.Spreadsheet -Version 49.0.1324-hotfix

Does this solve your issue?

Regards,
Mario

Hey Mario,

The fixed version is working well.
Thanks for your help!