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

Free Support Forum - aspose.com

Object reference not set to an instance of an object with Workbook.Save (mono / linux )

Trying Aspose Cell .net on linux / mono gives

Unhandled Exception: Aspose.Cells.CellsException: Object reference not set to an instance of an object
at Â..ÂÂystem.IO.Stream ) [0x00000] in :0
at Aspose.Cells.Workbook.Save (System.IO.Stream stream, Aspose.Cells.SaveOptions saveOptions) [0x00000] in :0
at Aspose.Cells.Workbook.Save (System.String fileName, Aspose.Cells.SaveOptions saveOptions) [0x00000] in :0

when i try to save a XLS to PDF.

Works fine on windows / visual studio 2012 but fails on Linux / mono

What could be the issue

Hi,

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

Please download and try the latest version: Aspose.Cells
for .NET v7.3.4.1
and see if it resolves your issue.

If your problem still occurs, then please provide us your source xls/xlsx file causing this exception and sample code you are using.

We will look into it and fix it or advise you asap.

I tried the new DLL but got the same issue

I have added a sample xls ( xml layout ) that we try to convert to PDF.

work perfect under windows but failes under mono linux

The c# code is simply following lines

workbook.CalculateFormula();

//Defind PdfSaveOptions
PdfSaveOptions pdfSaveOptions = new PdfSaveOptions();

//Set the compliance type
pdfSaveOptions.Compliance = Aspose.Cells.Rendering.PdfCompliance.PdfA1b;

workbook.Save(@"/tmp/test.pdf",pdfSaveOptions);

Hi,

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

We have found that output pdf works fine on windows with the latest version: Aspose.Cells
for .NET v7.3.4.1
. We will investigate this issue on Mono/Linux.

We have logged this issue in our database. We will look into it further and resolve this issue. Once the issue is resolved or we have some other update for you, we will let you know asap.

This issue has been logged as CELLSNET-41224.

Please also install Microsoft Fonts on your Mono/Linux Machine. It should also fix your problem.

In the latest fix and according to our design/model,
if a user does not install Microsoft Fonts, we will use suitable fonts
that he sets in Font Dir(s) i.e CellHelper.FontDir

If a user does not set the Font
Dir(s) accordingly in his code before conversion, and Aspose.Cells could
not find any font, an exception will be thrown accordingly. Also, if a
user uses “Arial” font in Excel, but only has free.ttf in the Font
Dir(s), we will only use free.ttf to show the text/contents.

I have attached the output pdf (windows) for a reference.

C#

string filePath = @“F:\Shak-Data-RW\Downloads\book1.xml”;


Workbook workbook = new Workbook(filePath);


workbook.CalculateFormula();


//Defind PdfSaveOptions

PdfSaveOptions pdfSaveOptions = new PdfSaveOptions();


//Set the compliance type

pdfSaveOptions.Compliance = Aspose.Cells.Rendering.PdfCompliance.PdfA1b;


workbook.Save(filePath + @".out.pdf", pdfSaveOptions);

Thanks you for the quick help.

I have set via CellHelper.FontDir = @"/opt/fonts"

and it works !

Hi,

Thanks for your feedback

It’s good to know that your issue is resolved using CellHelper.FontDir.

Let us know if you encounter any other issue. We will be glad to help you further.