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

Free Support Forum - aspose.com

Pivot table formatting into % and currency -$

How to format Pivot Table data into percentage and Currency (Certain rows in percentage and certain rows in Currency-$).
Please provide suggestions for this issue

Here in the image rows marked red should be in % format and rest all rows should be in dollar ($) format

and here is the code snippet for this issue:

index= pivotTable.addFieldToArea(PivotFieldType.DATA,pivotElements.get(key));
//Setting DataField to text Format


Could you please zip and share your current Excel file (containing the pivot table as per the image) by Aspose.Cells API and a sample Excel file containing your desired pivot table formatted as per your custom needs. You can create/update your desired pivot table in MS Excel manually to share here. We will check and help you through.


Attached zip file is the same pivot table as shown in the image that was attached in the forum. And also I attached a sample excel sheet with our desired outputs. Our need is to make only two columns as percentage format as shown in the desired output zip file. Please help us in this issue.



State Reconciliation (1).zip (150 KB)

Desired Output.zip (8.7 KB)


The pivot table is based on its source data in the sheet, so how come you could just apply different formatting for selected rows in data fields? You provided the output having static data which you have formatted using Format Cells dialog. Could you please share a sample Excel file having your desired formatted data in pivot table report (not in static data/table). We will check it soon.

Here is the data you asked for in pivot table format with our desired outputs (Whole State apport factor and Marginal Tax rate rows should be in % format).

And can we connect through call in teams if its feasible for you, so that we can discuss in detailed without any discrepancies.


Desired output State Reconciliation.zip (166 KB)

State Reconciliation (1).zip (150 KB)


Thanks for providing the file containing your desired pivot table with percentage formatting for your selected rows.

See the following sample code segment with comments on how to format selected row (you first need to find the row based on your desired pivot row field label/text) for your reference. You may refer to the code segment and write your own code or add your code based on your custom needs:
Sample code:

        Worksheet worksheet = workbook.getWorksheets().get(0);
        PivotTable pivotTable = worksheet.getPivotTables().get(0);

        //Find the cell containing the row field text/label
        Cell cell = worksheet.getCells().find("State Apport. Factor",null);

        //Create the style with your desired formatting
        Style style = workbook.createStyle();

        //Get the row index
        int row = cell.getRow();

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

        //browse the relevant row upto last column in the pivot table report
        //format each cell in the row to set percentage numbers formatting
        for (int i = start; i <= area.EndColumn; i++)

            pivotTable.format(row, i, style);



Hope, this helps a bit.

We are sorry but generally, we don’t provide technical support via phone or net meetings. The best way to get help is via forums and we can assist you better via forums threads.