We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Pivot table custom style in nodejs

Any one can give an example to apply custom style in node js - Pivot Table

@Vishnu_Vijay,

See the following sample code segment with comments using Aspose.Cells for Node.js via Java on how to format cells with custom formatting in your desired pivot field cells. You may find the row/col index based on your desired field label/text. You may refer to the code segment and write/update your own code or add your code based on your custom needs. I used a sample Excel file as an input file and directly update formatting accordingly.
e.g.
Sample code:

......
        var aspose = aspose || {};
        aspose.cells = require("aspose.cells");

        var wb = new aspose.cells.Workbook("Book1.xlsx");
        Worksheet worksheet = wb.getWorksheets().get(0);
        PivotTable pivotTable = worksheet.getPivotTables().get(0);
        pivotTable.refreshData();
        pivotTable.calculateData();

        //Find the cell containing the field text/label "APP"
        //update format of the cells in that column
        Cell cell = worksheet.getCells().find("APP", null);

        //Create the style with your desired custom formatting
        Style style = wb.createStyle();
        style.setCustom("0.00%");

        //Get the row and column index
        int row = cell.getRow();
        int col = cell.getColumn();

        //Get the cell area based on pivot table range
        CellArea area = pivotTable.getTableRange1();
        //Get the starting column index
        int start = area.StartRow;

        //browse the relevant row upto last row in the pivot table report
        //format each cell in the row to set percentage numbers formatting
        for (int i = start; i <= area.EndRow; i++)
        {
            pivotTable.format(i, col, style);
        }

        //Create another style for WEIGHT column
        Style style1 = wb.createStyle();
        style1.setNumber(1);

        //Find and update formatting for WEIGHT field
        cell = worksheet.getCells().find("WEIGHT", null);
        //Get the row/col index
        row = cell.getRow();
        col = cell.getColumn();

        //browse the relevant row upto last row in the pivot table report
        //format each cell in the row to set general formatting
        for (int i = start; i <= area.EndRow; i++)
        {
            pivotTable.format(i, col, style1);
        }

        wb.save("f:\\files\\out1.xlsx");

Also, see the document on format pivot table cells for your complete reference (Since Aspose.Cells for Node.js via Java is ported from Aspose.Cells for Java, so, you can refer to code segment for your reference).

Hope, this helps a bit.