Free Support Forum - aspose.com

Aspose.cells set font size and weight to bold

How can I change the font size and font weight to bold when using Aspose.Cells? I looked through the documentation and added the following, but it doesn't work:

String title = "Title";

Cell cell = cells.getCell(0, 0);

cell.setValue(title);

Style style = cell.getStyle();

Font font = style.getFont();

font.setColor(Color.BLUE);font.setBold(true);

font.setSize(20);

cell.setStyle(style);

Stefan


This message was posted using Aspose.Live 2 Forum

Hi Stefan,

please add a line style.setFont(font) to your sample code:

String title = “Title”;

Cell cell = cells.getCell(0, 0);

cell.setValue(title);

Style style =
cell.getStyle();

Font font = style.getFont();

font.setColor(Color. BLUE );font.setBold( true );
font.setSize(20);

style.setFont(font);

cell.setStyle(style);

You need to do this to work with the recent versions of the product. And we have already updated our online documents for the users, see the documents, e.g
https://docs.aspose.com/cells/java/data-formatting/
https://docs.aspose.com/cells/java/dealing-with-font-settings/

Kindly let me know if you still find any issue.

Thank you.