Excel to PDF conversion by Aspose.Cells - Long text data is cutting off even after applying auto-fit columns in .NET

Hello,

I am using cells to convert an excel document to a PDF. As part of the conversion I set the columns to Autofit the text. When I call auto fit on a worksheet that has long text int it the text it cut off and not included in the pdf. I tried changing some options but nothing seems to work. Is this a bug?

Files.zip (35.0 KB)
Here is an example of the code and I attached the excel doc, the actual and expected results:

        Workbook workbook = new Workbook(@"d:\input\AutoFit.xlsx");
        foreach(var sheet in workbook.Worksheets)
        {
            sheet.AutoFitColumns();
        }

        PdfSaveOptions options = new PdfSaveOptions();
        
        workbook.Save(@"d:\output\Expected.pdf", options);
1 Like

@ejt66

Thanks for using Aspose APIs.

We were able to observe this issue and logged it in our database for investigation and for a fix. Once, the issue is resolved or we have some other news for you, we will update you asap.

This issue has been logged as

  • CELLSNET-45698 - Worksheet.AutoFitColumns method cuts off the long text while rendering to Pdf

@ejt66

The long text is too long, when you autofit column, the column width is larger than the page width, in this case, the text is clipped.

Microsoft Excel has the similar issue when you have data in cell B1 (in your file), then autofit column A, you can see the text is clipped in the output/print preview.

Excel does the same thing, but it prints the content on the next pages.

When I auto fit the column using aspose cells the 2 additional pages are missing. Even if the column width is set from excel the content is still missing when saved to pdf from aspose.

I have attached a sample file with the columns width already set and output from excel and aspose. The aspose code was simply this:

        Workbook workbook = new Workbook(file);
        PdfSaveOptions options = new PdfSaveOptions();
        workbook.Save(@"d:\output\output.pdf", options);

Output.zip (171.0 KB)

@ejt66,

We know Microsoft Excel prints the content to next pages. But if you could print gridlines and headings (see my attachment “print_gridlines_headings.png”), in the printview, you will find Microsoft Excel actually prints the content to Columns B, C, …(see my attachment “printview.png”), although the content should be in Column A totally. So as we said Microsoft Excel also has the text being clipped issue if Cell B1 has data as we told you in the last post.
print_gridlines_headings.png:
print_gridlines_headings.png (68.0 KB)

printview.png:
printview.png (64.2 KB)

Now, I am afraid, we cannot do the same as Microsoft Excel for this strange behavior.

Thanks for your understanding!

@ejt66,

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

We have fixed your issue (logged earlier as “CELLSNET-45698”) now.

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

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

Thank you for solving my problem

@limingxuan
You are welcome! If you have other issues, please feel free to contact us.