Apply percentage number format to worksheet cells in Java

I checked the doc style - Aspose.Cells for Java - API Reference
and I didn’t find the support for the format like “0.0%” or “0.000%”

@larryyu1,

These are some selected (built-in) pattern supported when you use Style.setNumber() method. For your needs, you may use Style.setCustom() method to implement your desired formats (“0.0%” or “0.000%”). See the sample code segment for your reference.
e.g.
Sample code:

Workbook workbook = new Workbook();
Worksheet worksheet = workbook.getWorksheets().get(0);
Cell cell = worksheet.getCells().get("A1");
cell.putValue(.75);
Style style = cell.getStyle();
style.setCustom("0.0%");
cell.setStyle(style);
workbook.save("out1.xlsx");

Hope, this helps a bit.

it works.thank you for your quick reply.

@larryyu1,

You are welcome and good to know that your issue is sorted out by the suggested code segment. In the event of further queries or issue, feel free to write us back.