"GetRowHeightInch" returns wrong height for autofitted wrapped text with Calibri 10

See attached sample: I write a long text to a cell, set “IsTextWrapped = true” and call “AutoFitRows”.
AsposeCellsRowHeightInch.zip (11.9 KB)

When calling “GetRowHeightInch” afterwards (for setting horizontal page breaks at certain rows), this method returns sometimes wrong values.
It happens only when I load a template file that uses the (old) excel default font “Calibri”, but with nondefault size “10”. If I create a blank workbook, the font is “Arial 10”, and here it works. It also seems to work if the template uses “Calibri 11”.

With the “Calibri 10” template, “GetRowHeightInch” returns 0.53. Excel reports a height of 0.71:
rowheight_template.png (25.2 KB)
I switched the “Ruler Units” to “Inches” in excel.

Without template, “GetRowHeightInch” returns “1.06”, which is the same as excel:
rowheight_new.png (30.6 KB)

Some time ago, I created a similar issue: Calculating "PageSetup.Zoom" with HorizontalPageBreaks. As far as I understand the outcome of this issue, you made improvements to size calculations for a set of specific fonts. Is “Calibri 10” missing here? Is there a list of supported fonts?

Also, you should check it for the new Office365 font “Aptos Narrow”, here it does not work either.

@wknauf,

After an initial testing, I am able to reproduce the issue as you mentioned by using your template file and sample code snippet. I found “GetRowHeightInch” returns wrong height for auto-fitted wrapped text with Calibri 10.

We require thorough evaluation of the issue. We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): CELLSNET-56070

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

@amjad.sahi Also check it for “Aptos Narrow” please, the new default font.

@wknauf,

Sure, we have already noted it down (with the ticket) and will be evaluating it as well. Once we have an update on your issue, we will let you know here.

@wknauf
Excel’s behavior is very strange. In a normal view, three rows are sufficient, but Microsoft has set a height of four rows.
If you want to get size of print view, please try the following codes:

AutoFitterOptions afo = new AutoFitterOptions();
afo.AutoFitMergedCellsType = AutoFitMergedCellsType.LastLine;
afo.ForRendering = true;

Amazing, thanks, it works.

@simon.zhao is there a possibility of side effects (e.g. different row heights when opening the excel sheet)? In my real world sample I don’t see a visual difference whether I set “AutoFitterOptions.ForRendering = true” or not. I hope the only effect of this change is that “GetRowHeightInch” returns the proper value now.

For example (without Aspose.Cells involved) I have a two word text that seems to fit in one cell, but excel makes the row higher than necessary (upper part of screenshot). In Page layout view or print preview, I see that the text would be wrapped (lower part). So the normal excel view appears wrong, but it wraps differently when printing.
wrapped_text.png (2.8 KB)

@wknauf
Thank you for your feedback. You are welcome. After setting the AutoFitterOptions.ForRendering property to true, the auto fitted row height will be same as the result of MS Excel.
We are considering adjusting the default values of AutoFitterOptions.ForRendering as true to adapt to Excel’s default behavior.

@wknauf ,

The Normal View and Page Layout View(or Printview) are different. The Normal View is something like what you see in Excel, and Page Layout View is something what you see when printing or outputing(e.g. saving to pdf). The default autofitRow(without setting AutoFitterOptions.ForRendering ) is for Normal View. The autofitRow with setting AutoFitterOptions.ForRendering is for Page Layout View(e.g. printing, saving to pdf). If you want the result in Page Layout View, the autofitRow with setting AutoFitterOptions.ForRendering is OK for you.

@peyton.xu Thanks!

@wknauf
You are welcome. If you have any questions, please feel free to contact us.