This is a migrated thread and some comments may be shown as answers.

SetFontSize() doesn't set the correct font size.

2 Answers 589 Views
SpreadProcessing
This is a migrated thread and some comments may be shown as answers.
Richard
Top achievements
Rank 1
Richard asked on 20 Sep 2017, 10:10 PM

I'm using SetFontSize() to set the font size of a column. If set it to 10 then the size in the saved Excel document is 7.5. If I set it to 11, 8.5. 10.5 Shows as 8 but isn't really 8 because it's pixelated. Setting it to 8 in Excel shows a nice anti-aliased font.

So, how do I get SetFontSize() to set a real font size of 8 in Excel?

2 Answers, 1 is accepted

Sort by
0
Richard
Top achievements
Rank 1
answered on 25 Sep 2017, 02:15 AM
The same issue exists in column widths. Setting a width of 300 shows up as 42.14 in Excel.
0
Accepted
Polya
Telerik team
answered on 25 Sep 2017, 01:35 PM
Hello Richard,

The measurement units used in RadSpreadProcessing are device independent pixels (DIP). To set the desired value for the font size, you could use the PointToDip method of the Telerik.Windows.Documents.Media.Unit class:
worksheet.Cells[<rowIndex>, <columnIndex>].SetFontSize(Unit.PointToDip(8));

Regarding the width of the columns - on a worksheet, you can specify a column width between 0 and 255, which value represents the number of characters that can be displayed in a cell that is formatted with the standard font. You can find more information in this article.

That said, a column width of 300 pixels is equal to 42.14 of the specified above units of measurement. Could you please specify whether you want a 300 pixels width or 300 excel column width?

Regards,

Polya
Progress Telerik

Tags
SpreadProcessing
Asked by
Richard
Top achievements
Rank 1
Answers by
Richard
Top achievements
Rank 1
Polya
Telerik team
Share this question
or