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

Free Support Forum - aspose.com

Unable to apply font size to workbook

Hi Sir,
I am using below Code Snippet
But unable to apply font size on data in excel file I am using aspose-cells-8.8.0.jar

Below is my code snippet

String concPath = “C:\Users\vpadarthi\Desktop\ebs1223d\vishnu.xlsx”;
Workbook writeWorkbook = new Workbook(concPath);
Style defaultStyle = writeWorkbook.getDefaultStyle();
Font font = defaultStyle.getFont();
font.setSize(72);
font.setName(“Tahoma”);
writeWorkbook.setDefaultStyle(defaultStyle);
writeWorkbook.save(“C:\Users\vpadarthi\Desktop\ebs1223d\vishnu10.xlsx”,SaveFormat.XLSX);

Please find attached image where font size is not applying on data.data.jpg (109.5 KB)

@padarthi

It seems, this issue is related to your Excel file that you have used inside your code. Because, your code is working fine at our end.

Please provide us your vishnu.xlsx so that we could look into this issue further.

Hi Shakeel sir,
Thanks for your quick reply,
Please find below attached excel file in zip.
Thank you.

vishnu.zip (7.6 KB)

@padarthi

Default Style Font works only for those cells for which font has not already been applied. Please check TestFile.xlsx and its cell A1 and A2.

For cell A1, I have applied font.
For cell A2, I have not applied any font.

Now run your code with this Excel file. Please see this screenshot. Here you can see, font of cell A1 has not changed because it does not have default font, it has its own font. But the font of cell A2 has changed because it does not have its own font but it has a default font.

This is the reason; default font is not getting applied because all of your cells have their own fonts which will not be affected by default font.

Download Links:
Sample Test File.zip (5.9 KB)
sc.png (34.6 KB)

Screenshot