We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

The problem of Excel automatic Line-Changing

My excel is automatic system generation,when excel sets up many lines and a cell to wrap automatically. After generating pdf, only the first line has wrap at present, and the last few lines have not wrap automatically.such as attachments (aspose problem 1.png)
I found some information on the Internet about setting AutoFitRows () for Worksheets, because the excel template allows users to set the height of a line by themselves. If AutoFitRow is set for the whole, when the cell text does not need for automatic line break.The height of a line set by the user itself will fail without the need for automatic line-changing, such as attachments (aspose problem 2.png)
this is my code
Workbook workbook = new Workbook(sourcePath);
workbook.CalculateFormula();
workbook.Save((targetPath), Aspose.Cells.SaveFormat.Pdf);
attachment.zip

@easonyoung,

Thanks for the template files, screenshots and PDF files.

We will check your issues and get back to you soon.

@easonyoung,

Please try to AutoFit the rows with Aspose.Cells API and then let us know your feedback.

Workbook workbook = new Workbook("1000050_1007_798607.xls");
workbook.CalculateFormula();
Worksheet workSheet = workbook.Worksheets["ECS-20190327-000008"];
workSheet.AutoFitRows(true);
workbook.Save("1000050_1007_798607.pdf", SaveFormat.Pdf);

Thank you, this method is feasible, but there is still a problem, the size of the picture is different, excel pictures are set to adaptive, PDF pictures seem too small.problem.zip (177.8 KB)

@easonyoung,
We were able to observe the issue but we need to look into it more. We have logged the issue in our database for investigation and for a fix. Once, we will have some news for you, we will update you in this topic.

This issue has been logged as

CELLSNET-46663 - Image size changed while converting XLS to PDF after calling AutoFitRows(true)

@easonyoung,

We have investigated your issue a bit. The row height is auto matched and the stored row height in the file is not correct. MS Excel will automatically auto fit the row height when opening the file, then the row height will expand too. Aspose.Cells will work as MS Excel later.

So how can I solve this problem?

@easonyoung,

MS Excel adjusts the height while opening or viewing the file otherwise stored height is not correct. So I am afraid this difference can not be fixed for now and will be taken care later.

@easonyoung,

Please try our latest version/fix: Aspose.Cells for .NET v19.3.3 (attached)

Your issue should be fixed in it. See the following sample code for your reference:
e.g
Sample code:

             LoadOptions options = new LoadOptions();
            AutoFitterOptions fitOptions = new AutoFitterOptions();
            fitOptions.OnlyAuto = true;
            options.AutoFitterOptions = fitOptions;
            Workbook workbook = new Workbook(Constants.sourcePath + "CellsNet46663.xls", options);

Let us know your feedback.
Aspose.Cells19.3.3 For .Net2_AuthenticodeSigned.Zip (4.8 MB)
Aspose.Cells19.3.3 For .Net4.0.Zip (4.9 MB)

The issues you have found earlier (filed as CELLSNET-46663) have been fixed in Aspose.Cells for .NET v19.4. This message was posted using BugNotificationTool from Downloads module by Amjad_Sahi