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)
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.
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.
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)
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.
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.
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:
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,
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