@SakethDodda,
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:
e.g.
Sample code:
.......
Worksheet worksheet = workbook.getWorksheets().get(0);
PivotTable pivotTable = worksheet.getPivotTables().get(0);
pivotTable.refreshData();
pivotTable.calculateData();
//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();
style.setCustom("0.00%");
style.getFont().setName("Calibri");
style.getFont().setSize(11);
//Get the row index
int row = cell.getRow();
System.out.println(row);
//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);
}
workbook.save("f:\\files\\out1.xlsx");
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.