Version: 19.0.0-alpha-20
Build #: 54548
Build Date: 2017-May-31 10:02:46 AM
AQExcelSpreadsheet to insertPivotTable method gives Null Pointer Exception
1. With the latest changes for ADS #
15284 the below script to save an Excel gives Null Pointer Exception
2. Broken in build 19.0.0-alpha-20, Build #: 54548 and Build Date: 2017-May-31 10:02:46 AM
3. Works fine in Version: 19.0.0-alpha-19, Build #: 54539 and Build Date: 2017-May-30 03:47:16 PM
4. Works fine in ADS v18 latest build as well.
The default Spreadsheet Format under File > General is Excel 2007
The script is under our Data/AquaScripts/AQExcelSpreadsheet with name clear.xjs. Also attached here
AquaScript
==========
// define the output EXCEL file
var ExlFile = "/Users/tariq/Desktop/test_clear.xls";
var pivotTable = aqua.data.newPivotDataSet();
pivotTable.addColumnField("shiporder");
pivotTable.addColumnField("date");
pivotTable.setDataSet(generateDataSet());
pivotTable.calculateGrid();
// create an Spreadsheet Writer
var ExlSp = aqua.data.excelSpreadsheet(ExlFile);
ExlSp.insertPivotTable(pivotTable);
ExlSp.save(ExlFile);
aqua.console.println("Data Set written to EXCEL File: " + ExlFile);
// clear the spreadsheet
ExlSp.clear();
aqua.console.println("Spreadsheet is cleared");
// save the spreadsheet again
ExlSp.save(ExlFile);
aqua.exit();
function generateDataSet(){
// define a data set
var columns = ["shiporder", "date"];
var ds = aqua.data.newDataSet(columns);
// add dataset row with values
ds.addRowWithValues("Alappuzha", "12-12-2012");
ds.addRowWithValues("Alappuzha", "12-11-2012");
ds.addRowWithValues("Ernakulam", "07-05-1998");
ds.addRowWithValues("Idukki", "01-02-1999");
ds.addRowWithValues("Kalady","03-04-2000");
ds.addRowWithValues("Kollam", "05-06-2001");
ds.addRowWithValues("Kannur", "07-08-2002");
ds.addRowWithValues("Kasaragod", "09-10-2003");
ds.addRowWithValues("Kottayam", "11-12-2004");
ds.addRowWithValues("Kozhikode", "03-03-2005");
ds.addRowWithValues("Malappuram","06-06-2006");
ds.addRowWithValues("Palakkad", "08-08-2007");
ds.addRowWithValues("Pathanamthitta", "07-08-2002");
ds.addRowWithValues("Thrissur", "09-10-2003");
ds.addRowWithValues("Thiruvananthapuram", "11-12-2004");
ds.addRowWithValues("Wayanad", "03-03-2005");
// to convert the date from string to a AQDate object
format = new java.text.SimpleDateFormat("MM-dd-yyyy");
for(i=0; i<ds.rowCount; i++)
{
row = ds.get(i);
value = row.get(1);
try
{
date = format.parse(value);
row.set(1, date)
}
catch(e)
{
// Exceptions if any
print(e + " " + value);
}
}
return ds;
}
Exception
==========
java.lang.NullPointerException
at \\.\\.\\हिñçêČάй語简�?한\\.pꑉ⢩ꈍ⣉36.a(Unknown Source)
at \\.\\.\\हिñçêČάй語简�?한\\.uꇆꑍᛤ͈.a(Unknown Source)
at \\.\\.\\हिñçêČάй語简�?한\\.uꇆꑍᛤ͈.a(Unknown Source)
at \\.\\.\\हिñçêČάй語简�?한\\.uꇆꑍᛤ͈.a(Unknown Source)
at \\.\\.\\हिñçêČάй語简�?한\\.uꇆꑍᛤ͈.a(Unknown Source)
at \\.\\.\\हिñçêČάй語简�?한\\.uꇆꑍᛤ͈.a(Unknown Source)
at \\.\\.\\हिñçêČάй語简�?한\\.uꇆꑍᛤ͈.a(Unknown Source)
at \\.\\.\\हिñçêČάй語简�?한\\.uꇆꑍᛤ͈.a(Unknown Source)
at \\.\\.\\हिñçêČάй語简�?한\\.uꇆꑍᛤ͈.a(Unknown Source)
at \\.\\.\\हिñçêČάй語简�?한\\.bꑴꍨꇶenuminterface.insertPivotTable(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.mozilla.javascript.MemberBox.invoke(Unknown Source)
at org.mozilla.javascript.NativeJavaMethod.call(Unknown Source)
at org.mozilla.javascript.optimizer.OptRuntime.call1(Unknown Source)
at org.mozilla.javascript.gen.c_1._c_script_0(:13)
at org.mozilla.javascript.gen.c_1.call()
at org.mozilla.javascript.ContextFactory.doTopCall(Unknown Source)
at org.mozilla.javascript.ScriptRuntime.doTopCall(Unknown Source)
at org.mozilla.javascript.gen.c_1.call()
at org.mozilla.javascript.gen.c_1.exec()
at org.mozilla.javascript.Context.evaluateString(Unknown Source)
at \\.\\.\\हिñçêČάй語简�?한\\.eꉠꃃꁜꐃ7transient.dJ(Unknown Source)
at com.aquafold.aquacore.open.fꏳꇘꐜꋏcontinue.run(Unknown Source)
at java.lang.Thread.run(Thread.java:745)
@tariq: does this occur in v18 & prior versions as well?