We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Null-reference exception during Save if worksheet was copied from another workbook

Hi Aspose team,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

I’ve faced with quite critical issue (for me) which prevents me from saving workbook. Detail: I’m opening source workbook which is just an empty worksheet with some named-ranges defined.

Next step – I’m creating new workbook and copy worksheet from source workbook to a new one. Last step – saving workbook in SaveFormat.Xlsm. During the save Aspose.Cells falls with Null-reference exception.

You can find attached the Source file as well as simple code.

If possible could you please investigate what causes the issue?

Thank you in advance.


Thanks for your posting and using Aspose.Cells for .NET.

Please download the latest version:
for .NET v7.1.1.1

And use the following code instead. Let us know if it works fine for you.


string path = @“F:\Shak-Data-RW\Downloads”;

var sheets = new[]


“Analog Values”


var loadOptions = new LoadOptions(LoadFormat.Auto)


LoadDataOnly = false,

ParsingFormulaOnOpen = true,

ConvertNumericData = false,


var source = new Workbook(path + @“Source.xls”, loadOptions);

var dest = new Workbook();

foreach (var sheetName in sheets)



var destWorksheet = dest.Worksheets[sheetName];

var sourceWorksheet = source.Worksheets[sheetName];



var saveOptions = new OoxmlSaveOptions();

// Next line throws null-reference exception

dest.Save(path + @“Output.xlsx”, saveOptions);

Thank you for the quick feedback.

I've tried the code you sent me and it works fine. Sorry, I didn't knew about OoxmlSaveOptions. Now everithing clear.

Thank you.

Hi Aspose team,

The workaround worked fine in case if destination workbook was made from scratch. By if it is opened from the attached template file the Aspose.Cells crushed ad described above during the save.

In the attachment you can find the the code I'm using (Program.zip), source file (Source.xls) and the template file (Template.xlsm).

Could you plase take a look and if there is no workaround for this issue please provide a fix?

Thank you in advance.


I can find the exception on the final Workbook.Save() method as you have pointed out by running your code with your files.

I have logged a ticket with an id: CELLSNET-40405. We will look into it soon.

Thank you.


Please download and try this fix: Aspose.Cells for .NET


The issues you have found earlier (filed as CELLSNET-40405) have been fixed in this update.

This message was posted using Notification2Forum from Downloads module by aspose.notifier.