V7.0.1 of Cells for Java is throwing an NPE when trying to save

I've tried several things to get the Workbook.save() method to save, but everytime i try i get the following stack trace:

java.lang.NullPointerException
at com.aspose.cells.b.a.b.g.(Unknown Source)
at com.aspose.cells.b.a.b.g.(Unknown Source)
at com.aspose.cells.pk.a(Unknown Source)
at com.aspose.cells.pk.a(Unknown Source)
at com.aspose.cells.pk.a(Unknown Source)
at com.aspose.cells.Worksheet.autoFitRow(Unknown Source)
at com.aspose.cells.kw.a(Unknown Source)
at com.aspose.cells.WorksheetCollection.r(Unknown Source)
at com.aspose.cells.WorksheetCollection.a(Unknown Source)
at com.aspose.cells.WorksheetCollection.b(Unknown Source)
at com.aspose.cells.WorksheetCollection.a(Unknown Source)
at com.aspose.cells.WorksheetCollection.a(Unknown Source)
at com.aspose.cells.Workbook.a(Unknown Source)
at com.aspose.cells.Workbook.save(Unknown Source)

The code i used ranged from my own to the sample included in the JavaDoc:

//Open a designer file
String designerFile = "designer.xls";
Workbook workbook = new Workbook(designerFile);

//Set scroll bars
workbook.setHScrollBarVisible(false);
workbook.setVScrollBarVisible(false);

//Replace the placeholder string with new values
int newInt = 100;
workbook.replace("OldInt", newInt);

String newString = "Hello!";
workbook.replace("OldString", newString);
XlsSaveOptions saveOptions = new XlsSaveOptions();
workbook.save("result.xls", saveOptions);

I've tried several combinations of how save is called including creating a workbook from scratch (not from an existing file) and writing to an output stream (the method i intend to use). I even fixed the code by wrapping save in a try-catch so it would compile.

Reverting back to version 2.5.4 allows me to save files, but there are other issues involving an inability to sort and problems when using the auto filter. Is there anything we can do to get save working so i can use v7?

Hi,

Please provide us your source xls/xlsx files so that we could test this issue and report to our developers.

Please also try the latest version:
Aspose.Cells for Java v7.0.1.5

Well, unfortunately the issue wasn't with using a particular workbook. I tried both opening an existing file (which was just a blank file saved from Excel 2010), and creating a worksheet from scratch using new Workbook(). Neither method allowed me to save the file. Attached is a blank file for you though.

Using 7.0.1.5 also didn't fix the problem for either saving to a file or to streaming output when working with a newly created workbook.

Hi,

I am unable to reproduce the exception using your code and the provided xls file.Please provide a code/source files that could replicate this problem.

Hi,

Please make sure, you have added all the additional java libraries needed by V7.0.0 and later in your classpath.

You can download them from this link:

<a href="">Additional Java Libraries For V7.0.0 and Later</a>

Hi,

Please try setting correct font path before saving the excel file and see whether your issue can be solved. Also we will try to make enhancement to catch such kind of exception in later fixes.

Thanks for the suggestion. It appears as though this was a version issue.

I am currently working in a Maven project that has existing dependencies which are similar to the dependencies you have but of different versions. It appears as though an incorrect version of a dependency was loaded. I tried a standalone project (outside of Maven) with the dependencies you provided and it worked just fine.

Hi,

It’s good to know that you were finally able to sort out your problem.