Pivot tables toJson issue

Posted by: kmalyi on 16 July 2021, 2:00 am EST

    • Post Options:
    • Link

    Posted 16 July 2021, 2:00 am EST

    Hello we got a problem and would be happy if you can help us. Workflow is more complicated then described in code but this sample still doesn’t work too.

        public void pivotTest() throws Exception{
            String data = IOUtils.toString(
            Workbook workbook = new Workbook();
            //data contains two worksheets (first is primary and second with Pivot table)
            IWorksheet worksheetWithPivot = workbook.getWorksheets().get(1);
            String worksheetWithPivotJson = worksheetWithPivot.toJson();
            String workbookJson = workbook.toJson();
            //we want to create new duplicated workbook and add worksheet with Pivot
            Workbook workbookNew = new Workbook();
            IWorksheet add = workbookNew.getWorksheets().add();
            // on add.fromJson(worksheetWithPivotJson)  we have Exception
    //        caused by: java.lang.NullPointerException
    //        at com.grapecity.documents.excel.r.ao.a(Unknown Source) ~[gcexcel-4.1.3.jar:?]
    //        at com.grapecity.documents.excel.D.aw.a(Unknown Source) ~[gcexcel-4.1.3.jar:?]
    //        at com.grapecity.documents.excel.D.aw.a(Unknown Source) ~[gcexcel-4.1.3.jar:?]
    //        at com.grapecity.documents.excel.di.fromJson(Unknown Source) ~[gcexcel-4.1.3.jar:?]
    //        at com.grapecity.documents.excel.di.fromJson(Unknown Source) ~[gcexcel-4.1.3.jar:?]
  • Posted 16 July 2021, 2:02 am EST

    Here is Json with dataGrapecityDataJson.zip

    Please let me know if you need more information about this issue. Thanks!

  • Posted 18 July 2021, 9:16 pm EST


    We have escalated this issue to the development and will let you know as soon as we get the update from their end.

    [Internal Tracking ID: DOCXLS-4531]


    Prabhat Sharma.

  • Posted 19 July 2021, 3:35 pm EST


    As per the developers, the Pivot table is stored in the worksheet while the pivot cache is stored in the workbook that different pivot tables shared.

    So when using worksheet tojson, pivot cache info would be lost. And some error would happen when using worksheet from json.

    If you want to use PivotTable, you should use workbook.fromjson and remove unwanted sheet in order to preserve the pivot cache info.


    Prabhat Sharma.

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels