PageSetup.FitToPagesWide/FitToPagesTall and "Page Layout" view

His is actually a followup to https://forum.aspose.com/t/setcolumnwidthinch-issue/226518: attached is a modified sample:
ColWidth.zip (33.0 KB)
The sample sets “PageSetup.FitToPagesTall = 1” / “PageSetup.FitToPagesWide = 1”.

When opening the result file and switching to the “Page Layout” view, the last col does not fit the page and overlaps to the next page (upper half of attached screenshot).
pagesetup_view.png (52.3 KB)

Now click the “print” button => the preview shows that now the columns fit on one page.

After returning to the “Page Layout” view, all columns fit on one page. See screenshot, lower part.

Is this an excel issue or can there anything be improved?

Best regards

Wolfgang

@wknauf,

Yes, I tested and found the same behavior. It looks like this is something to do with “Paget Layout” and MS Excel’s behavior itself. Anyways, we will further evaluate and get back to you with more details on it.

@wknauf

Please using the following code, it will be OK.

Workbook workbook = new Workbook("..\\..\\template_Calibri.xlsx");

Worksheet sheet = workbook.Worksheets[0];

...

sheet.PageSetup.FitToPagesTall = 1;
sheet.PageSetup.FitToPagesWide = 1;

OoxmlSaveOptions saveOptions = new OoxmlSaveOptions(SaveFormat.Xlsx);
saveOptions.UpdateZoom = true;

workbook.Save("result.xlsx", saveOptions);

Hi,

this sounds very promising and works fine for the original sample. But when the workbook has a default font other than “Calibri”, the “Page Layout” view is wrong the first time: the ruler goes to 29 and an empty column (from the next page) is displayed at the end of the page.
It works if you switch to another view and back. But unfortunately, our real world template has the default view “Page Layout”, thus the issue is noticed.

Attached a reworked sample: it loads a template with default font “Calibri” (this works) and another with default font “Times New Roman” (this is broken) and creates result files.
ColWidth_2021-03-11.zip (41.1 KB)
For compiling the sample, you probably have to call “Restore Nuget packages”.

The screenshot shows the difference:
results.png (45.7 KB)

Best regards

Wolfgang

@wknauf

I can see the issue in your generated file “result_TimesNewRoman.xlsx”. However, the template file “template_TimesNewRoman.xlsx” is missed in your shared project. Please share it to us, we will create a ticket for it.

Sorry, cleaned up the wrong files in the zip. Here is “template_TimesNewRoman.xlsx”:
template_TimesNewRoman.zip (7.1 KB)

Best regards

Wolfgang

@wknauf,
Thank you for the template file. We have analyzed the issue and logged a ticket for further investigation. You will be notified here once any update is ready for sharing.

This issue is logged as:
CELLSNET-47923 - Improper page layout view for workbook having default font other than Calibri

@wknauf

Please try our latest version/fix: Aspose.Cells for .NET v21.3.1 (attached).
Aspose.Cells21.3.1 For .Net2_AuthenticodeSigned.Zip (5.5 MB)
Aspose.Cells21.3.1 For .Net4.0.Zip (5.5 MB)
Aspose.Cells21.3.1 For .NetStandard20.Zip (5.5 MB)

Your issue should be fixed in it.

Let us know your feedback.

Hi,

thanks, I can confirm that it works now. Thanks for the great support!

Best regards

Wolfgang

@wknauf,
You are welcome.

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