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

Free Support Forum - aspose.com

Set default font name and size for entire workbook

I would like to set the font “Calibri (Body)” and the same font size for the entire workbook. not matter what was predefine.
for some reason, when I’m using that code (and this one is the last action before saving the file):
(from this thread)

        var style = workbook.CreateStyle();
        Font font = style.Font;
        font.Name = "Calibri (Body)";
        font.Size = 14;
        workbook.DefaultStyle = style;

I got some mix between a few fonts and sizes. (attached here excel and pdf )
any idea what I can do to set the workbook to be always with the same font and size?

Maybe Calibri is some special font and I should configure this ? (I can see there are rows with the Calibri so not sure if this is the correct path)

font out example pdf an excel.zip (222.8 KB)


Thanks for the sample files.

DefaultStyle would be effective for new Workbook or uninitialized cells. To set your desired font for an existing Workbook, you may apply the style to the worksheet cells/range of cells. See the sample code segment for your reference:
Sample code:

var style = workbook.CreateStyle();
Aspose.Cells.Font font = style.Font;
font.Name = "Calibri (Body)";
font.Size = 14;
StyleFlag flag = new StyleFlag();
flag.FontName = true;
flag.FontSize = true;
Range range = workbook.Worksheets[0].Cells.MaxDisplayRange;
range.ApplyStyle(style, flag);

workbook.DefaultStyle = style;

Hope, this helps a bit.

that was very helpful, thank you very much


Good to know that the suggested code segment works for your needs. Feel free to write us back if you have further queries or comments.