Object reference exception Excel to PDF

If I want to convert excel file (attached) to pdf, I get this exception.

Exception Details:
Bitworks.eQMS.UnitTest.AsposeTest.GeneratePDFFromExcel:
Aspose.Cells.CellsException : Object reference not set to an instance of an object.

Stack:
at Š.”.Š›(Stream )
at Aspose.Cells.Workbook.Save(Stream stream, SaveOptions saveOptions)

Thanks

Hi,

Thanks for using Aspose.Cells for .NET.

I have tested your issue with the latest version:
Aspose.Cells
for .NET v7.3.0.3
and found it is working fine.

I have attached the output pdf generated with the following code. Please download and check it.

C#


string filePath = @“F:\MS_Excel_Datei_(Fehlermeldung).xlsx”;


Workbook workbook = new Workbook(filePath);

workbook.Save(filePath + “.out.pdf”);


Hi,

I think problem is font type: ConduitITCStd Light
If I change font type to e.g. Arial, I don’t get the error.

In your working enviroment I think there is no font type like ConduitITCStd Light, so it’s automatically changed to Arial or sth. like this.

Is this a general problem?

Hi,

Thanks for your feedback.

Could you please provide ConduitITCStd Light font so that I could test it on my end?

Also, you could try setting the font directory like this.

C#


CellsHelper.FontDir = @“D:\WINDOWS\Fonts”;


//Rest of the code goes here

I attached fonts …

Hi,

Thanks for your fonts.

I have installed the fonts on my Windows XP and re-run the code and I was not able to replicate this issue using the latest version:
Aspose.Cells
for .NET v7.3.0.3


Below is a screenshot for your reference.

I have also attached the output pdf, please check it.

Screenshot:

Hi,

the problem is still alive.
If i change italic font style to normal the problem doesn’t occur.

But if there is an italic font style element with font type “Conduit” pdf creation crashes with reported exception.

I attached file one more time.

Hi,

Thanks for using Aspose.Cells.

Please download and try the latest major release:

Aspose.Cells for .NET 7.3.1

and let us know your feedback.

I have attached the generated pdf using the following code with the above version.

C#



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


Workbook workbook = new Workbook(filePath);


PdfSaveOptions opts = new PdfSaveOptions();

opts.OnePagePerSheet = true;


workbook.Save(filePath + “.out.pdf”, opts);


Hi,

I still get this error.
Your example isn’t buidlable with the latest code of 7.3.1.

There is no Option “OnePagerPerSheet” in PDFSaveOptions and there is no method taking PDFSaveOptions as argument in workbook.Save method.

Do you use another newer … version of Cells?

Hi,


I think you might be using the wrong Aspose.Cells.Dll file in your project.

Please use the Aspose.Cells.Dll under “net2.0” folder.

Moreover, please check the topic:

We have three .NET framework compiled versions:
1) .net 1.x → it is used for for .net1.x frameworks.

2) net2.0 → that is compiled for any CPU (32bit or 62 bit). This library is for 32 bit and 64 bit systems or environments i.e…, for all kinds for frameworks which are equal or greater than 2.0, so this would work equally fine on .NET framework 2.0, 3.0, 3.5, 4.0 etc.
3) net 3.5 client profile version…> which will work for .net3.5 and .net4.0 client profile framework versions.

Thank you.

Sorry,

but I’m using the right dll (it’s not the first time I’m working with your components)

I attached overview of save methods using .Net Reflector and overview of dll details from explorer info.

Hi,

Chris2Stein:


I still get this error.
Your example isn't buidlable with the latest code of 7.3.1.

There is no Option "OnePagerPerSheet" in PDFSaveOptions and there is no method taking PDFSaveOptions as argument in workbook.Save method.


This is strange. Please create a sample application with v7.3.1, zip it and post it here to show the issue. We will check it soon.

Thank you.

I attached console app project (VS 2010) - without licence.

Please ensure to have installed correct font types!

Hi,


I have run your project, it works fine. The output PDF file is generated fine, it does not give me any error. I have attached your project (updated for a minor change, i.e… “workbook.Save(“MS_Excel_Datei_(Fehlermeldung).out.pdf”);” --> used the line to generate the PDF into my “AsposeCellsTest\bin\Debug” folder: ), please refer to the attached project.

Thank you.

Hi,

we still have this problem using Cells 7.4.2.5 (.NET 2.0)
I think, problem is font ConduitITCStd Light italic like described in earlier posts.

I attached fonts, please be sure to have this font installed on your System.
(open Excl file and check, if font is ConduitITCStd Light italic)

Thanks

Hi,

Thanks for your posting and using Aspose.Cells.

Please remove otf font and convert otf to ttf using http://www.font2web.com and reinstall it.

It will solve your issue.

Hi,

now I had time to check and after changing server font types it worked fine.
Thank you.

Hi,

Thanks for your feedback.

It is good to know your issue is resolved now. If you face any other issue, please feel free to post on our forum, we will be glad to help you further.