Text is clipped in printer output after call to "AutoFitRows"

See attached sample: the text in cell 1/1 fits perfectly in “Normal” view. But when switching to “PageLayout” view or print preview, it is wrapped and thus the second line of cell content is clipped.
error.png (6.3 KB)

AsposeCellsClippedText.zip (18.2 KB)

This seems to result from a combination of several steps:
a) I load a template which uses “Calibri” font.
b) I want to set the column width to 3 centimeters, following the approach from https://forum.aspose.com/t/setcolumnwidthinch-issue/226518/5 - excel displays the column width as “2.99”, but this small difference is OK for me.
c) finally I call “AutoFitRows” for this row.

If the “AutoFitRows” call is ommitted, the row is higher, but the cells seems to be too high in “Normal” view.

Could you take a look at this?

For your information: I am on vacation next week, so my replies might be delayed.

Best regards

Wolfgang

@wknauf,

I manually tried the steps in MS Excel and found the same behavior as per the output Excel file by Aspose.Cells APIs. If you see or set some width in page layout view, it will be retained in other view and vice versa. For example, for the line


//If this line is removed, the cell has a different height:
sheet.AutoFitRows(1, 1, afo);

since you do not specify wrapping text attribute in normal view, so when you apply autofit row operation upon it, it will set minimum height (single line height) of the row. So, you will get same view in PageLayout view. Similarly if you increase/decrease some height/width in PageLayout view, it will be retained in other view types. I do not think this is an issue with Aspose.Cells APIs rather behavior of MS Excel. If you still think it is an issue with Aspose.Cells APIs, kindly do share your expected file, we will check it soon.

Sorry, I fear I don’t understand your reply :frowning_face:

But in excel, there is an option to auto fit rows, and when clicking this function in the result of my code sample, the resulting cell is higher, though the text still does not wrap. See screenshot. Here, it looks “strange” in the Normal View, but it would work when printing.
excel_autosizerow.png (38.5 KB)

Best regards

Wolfgang

@wknauf,

We request you to kindly do share your desired file to differentiate height/width for row/column, you may create the Excel file manually in MS Excel. We will surely check your issue thoroughly.

Hi,

attached is an original file created by our code (“original.xlsx”) and a file that is modified by clicking the excel button “Auto fit row height” (“after_clicking_automatic_rowheight.xlsx”). The problem occurs e.g. in cell H6 or H10.
sample_files.zip (22.8 KB)
The latter file works when printing. In the first file, the texts in cells H6 and H10 are clipped.

Our code uses the same call to “AutoFitRows” that is shown in the sample project attached to my initial post.

Hope this is what you requested me to do.

Best regards

Wolfgang

@wknauf,

Could you call auto-fit row(s) operation when you set wrapping text on for PageLayout view if it works for your needs (you do not need to call auto-fit rows operation at the end for Normal view anymore) :
e.g.
Sample code:

------
              AutoFitterOptions afo = new AutoFitterOptions();
              afo.AutoFitMergedCellsType = AutoFitMergedCellsType.LastLine;

              Style style = sheet.Cells[1, 1].GetStyle();
              //style.SetBorder(BorderType.LeftBorder | BorderType.RightBorder | BorderType.BottomBorder, CellBorderType.Thin, Color.Black);
              style.IsTextWrapped = true;
              sheet.Cells[1, 1].SetStyle(style);
              sheet.AutoFitRows(1, 1, afo);
              sheet.ViewType = ViewType.PageLayoutView; 
......

Let us know if you still find the issue.

Hi,

your snippet does not help, as it does not call “SetViewColumnWidthPixel”.

If I call “AutoFitRows” in PageLayoutView mode, the result is the same.

Best regards

Wolfgang

@wknauf,

Thanks for sharing further details.

We have logged an investigation ticket with an id “CELLSNET-49365” for your issue. We need to thoroughly evaluate your issue from all aspects. We will look into your issue soon.

Once we have an update on it, we will let you know.

@wknauf
Please try the latest fix 21.9.4.
Aspose.Cells21.9.4 For .Net2_AuthenticodeSigned.Zip (5.6 MB)
Aspose.Cells21.9.4 For .Net4.0.Zip (5.6 MB)
Aspose.Cells21.9.4 For .NetStandard20.Zip (5.6 MB)

Hi Simon,

sounds promising. But I am on vacation currently. I will do the testing on 11th Oct.

Best regards

Wolfgang

@wknauf,

Sure, please take your time to evaluate the suggested fix. Hopefully, it will fix your issue.

Have a good day!

I can confirm that it works now. Thanks for the great support, as always.

Best regards

Wolfgang

@wknauf,
Good to know that your issue is sorted out. Feel free to contact us any time if you need further help or have some other issue or queries, we will be happy to assist you soon.

The issues you have found earlier (filed as CELLSNET-49365) have been fixed in this update. This message was posted using Bugs notification tool by simon.zhao