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

Free Support Forum - aspose.com

Saving Workbook Error

Hi,

I am getting this error when trying to save a excel file:

{"Object reference not set to an instance of an object."} System.Exception {System.NullReferenceException}

at Aspose.Cells.Record.⍝..ctor(Name name)\r\n at Aspose.Cells.Worksheets.୎(਀ ۼ, Int32 ଘ)\r\n at Aspose.Cells.Worksheets.ୀ(਀ ۼ)\r\n at Aspose.Cells.Worksheets.ୄ(਀ ۼ)\r\n at Aspose.Cells.Worksheets.ୈ(FileFormatType ୆)\r\n at Aspose.Cells.Worksheets.ਁ(Stream ۼ, FileFormatType ୆)\r\n at Aspose.Cells.Workbook.Save(Stream stream, FileFormatType fileFormatType)\r\n

I try save with:

workbook.Save(fstream, FileFormatType.ExcelXP);

or

workbook.Save(docFile);

Same error. It only happens for one excel file, but I need to know what is exactly error and so can fix it.

I open the file, update hyperlink, and save it.

There is a pivot table within the file, may that be a problem?

Chang

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

Thank you for considering Aspose.

Well, the exception you are mentioning is basically a .NET exception which is thrown, when you are using some object without instantiating it. Please share your code and the template file, so we can figure out what the exact issue is. Also, which version of Aspose.Cells are you using? Please try the attached latest version. This latest version is much enhanced and improved from the previous versions.

Thank You & Best Regards,

Hi,

my code is pretty simple:

public bool FixExcelLinksByStream(string docFile) {
System.IO.FileStream fstream = null;
Workbook workbook = null;
try
{
fstream = new System.IO.FileStream(docFile, FileMode.Open);
workbook = new Workbook();
workbook.Open(fstream);
workbook.Save(fstream, FileFormatType.Default);

return true;

}
catch (Exception ex)
{
return false;
}
finally {
if (fstream != null)
fstream.Dispose();

workbook = null;
}
}

Open file, and save it, got error during save.

Attached the excel file for you to take a look. Like I said, it only happens to this excel file, seems like some internal data aspose.cell can't handle it right during save process.

I got excel file from user, so don't know how he created it, but just remove all worksheets, and enter a simple text, which is what I uploaded to you. However, if I copy all data into a new excel workbook, no error at all.

Thanks

Chang

Hi Chang,

Thanks for providing us the template file with sample code.

After a simple test, we can get the error you have mentioned. We will look into your issue to figure it out soon.

Thank you.

Hi Chang,

We have fixed the issue, please try the attached version (4.6.0.6).

Thank you.