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.

Thank you for the above sample code, this worked well but we are now stuck with other small issue i.e., the cells with value $0 are not appearing in the table after the code change. You can see the difference of above mentioned issue in the attached two sheets (Before and after the code change). Can you please give some solution for us regarding this. Thank you in advance.
State recon after code change.zip (142.1 KB)
State recon before code change.zip (140.7 KB)


Which version of the APIs you are using? Please try our latest version/fix: Aspose.Cells for Java v22.1. I have tested using my sample code with your (previous) original file and it works ok, those $0 are retained in the output Excel file.

Sorry for the previous issue I mentioned. Its not required for us. But when we are expanding those 2 rows that we have changed, they are again changing to $ . Can you provide the solution for it. And also can you tell me where the code (call) goes when we click on expand.
You can see in the below images while i expand that particular column it is again changed to $.
Capture.PNG (9.0 KB)
Capture1.PNG (8.7 KB)
Copy of State recon after code change.zip (40.3 KB)

Can you give the solution for this?


Could you please share your expected file, you may accomplish the task manually in MS Excel and save the Excel file to provide us. We will check it further.

We have logged a ticket with an id “CELLSJAVA-44408” for your issue. We will look into it soon.
Once we have an update on it, we will let you know.

we cant change the values in our report file. That is the reason i have attached the images in the previous dialogue box. The issue is, after expanding the State Apport. Factor row and Marginal Tax rows, they are again changing to $ from % format. I hope you got this.


Yes, we understand your requirements. We have already logged a ticket with an id “CELLSNET-50356”. Either we will devise a code snippet or figure out the issue with enhanced APIs to support your needs.

Okay, Thank you Amjad.


You are welcome.

Can we get an ETA for this?


We will check if we could provide you an ETA on it. We will get back to you soon with updates.


We are working over the issue and hopefully it will be fixed before the end of this week.

This email is from a contractor that provides managed services to 3rd parties, including Thomson Reuters.

Sure, Thank you


You are welcome.