Hi,
I am getting Null pointer Exception in Aspose 8.8.0 (Working fine in 8.3.0) While adding new pivotTable to PivotTableCollection
Below is my code snippet:-
====================
writeWorkbook.getWorksheets().add(“Test Data Sheet”);
pivotWorkSheet = (WorkSheet)writeWorkSheets.add(“Pivot”);
PivotTableCollection pivotTables = pivotWorkSheet.getPivotTables();
String cellString = “M202”;
int index = -1;
try{
index = pivotTables.add(“Test Data Sheet”+ “!$A$1:” + cellString, “A1”,“Test Pivot Name”);
}catch(Exception e){
System.out.println(e.getMessage());
e.printStackTrace();
}
Getting Null pointer Exception.
Please Help Me !!
Note: - Genrated class file On 8.3.0 and Runned the generated class file on 8.8.0
Hi,
By the way, there is no “WorkSheet” class in Aspose.Cells for Java APIs, the class name is “Worksheet” instead, so could you evaluate your sample code and make sure you are using correct classes, interfaces, constants (enumerations) or other members from com.aspose.cells package APIs (you may check the API reference docs). If you still have any issue, kindly do paste your runnable sample code (JAVA program), so we could evaluate your issue properly.
Thank you.
Its a spelling mistake while typing
I am using proper classes
I came to a conclusion that
If we have space or spaces in the datasheet name we are getting below exception.(Working fine in 8.3.0)
( Not working fine in 8.8.2 file showing repaired message and pivot table not working in 8.8.2)
I got below exception when run using 8.8.0
16/06/07 18:56:01 java.lang.NullPointerException
at com.aspose.cells.PivotFieldCollection.(Unknown Source)
at com.aspose.cells.zbtf.(Unknown Source)
at com.aspose.cells.PivotTable.(Unknown Source)
at com.aspose.cells.PivotTableCollection.a(Unknown Source)
at com.aspose.cells.PivotTableCollection.add(Unknown Source)
at com.aspose.cells.PivotTableCollection.add(Unknown Source)
Please help regarding this.
Hi,
We need to check your data source (on how you are using/ filling data into the cells in the worksheet) for your underlying PivotTable. Please provide us complete runnable sample code (JAVA program) with template files (input (if any) and output files) to reproduce the issue with v8.8.2, we will check your issue soon.
Thank you.
Hi,
I am afraid, you haven’t provided us what is requested in my previous reply, so we cannot evaluate your issue properly.
By the way, could you try to replace the line of code:
i.e.,
index = pivotTables.add(“Test Data Sheet”+ “!$A$1:” + cellString, “A1”,“Test Pivot Name”);
with:
index = pivotTables.add("‘Test Data Sheet’!$A$1:" + cellString, “A1”,“Test Pivot Name”);
if it works fine?
Thank you.
Working fine If we append Single Quote first and last
Now problem is If the data sheet name contain single quote,Pivot Table is not fetching data from data sheet.
Anyway fine for now.
Thank you so much for your help.
Hi,
Good to know that your issue is sorted out now.
Let us know if you have any other query or issue, we will be happy to assist yous soon.
Thank you.