Question About Font Size

I’m setting a worksheet’s font name and font size using ExcelWorksheet.Cells.Style.Font.Name and ExcelWorksheet.Cells.Style.Font.Size. I want to use the ARIAL font with a font size of 10 points. I’ve quickly found that in order to set the size correctly I need to multiply the desired font size by 20. Why does it have to be multiplied by 20? I’m adding a comment to my code saying that I have to multiply by 20 but I’d like to be able to put something in there besides “for some reason it has to be multiplied by 20”. I tried searching the online documentation but I couldn’t find anything.

Thanks,

Scott

Hi Scott,

The ExcelFont.Size property is in twips unit which is 1/20th of a point.

So to set the property to some desired point value you would multiply it by 20, or use this:

cell.Style.Font.Size = (int)LengthUnitConverter.Convert(10, LengthUnit.Point, LengthUnit.Twip);

Regards,
Mario