Excel to PDF - Getting symbols "####" in merged cells

Hello Team,

When I am trying to save the Excel file as Pdf I am getting “####” symbols in output for merged cells. Please find the attached xls file and generated pdf file from your reference. I used the following two statements to generate pdf:

Aspose.Cells.Workbook sampleWorkbook = new Aspose.Cells.Workbook(@“D:\Sample.xls”);
sampleWorkbook.Save(@“D:\Sample.pdf”, new Aspose.Cells.PdfSaveOptions(Aspose.Cells.SaveFormat.Pdf));

I am using the 8.5.0.0 version of Aspose.Cells.dll.

Request you to please do let me know how should I get rid of these unnecessary symbol “#” from output pdf. Looking forward for your valuable inputs.

Thanks,
Shweta

Hi,

Thanks for your posting and using Aspose.Cells.

You should use the AutoFitterOptions.AutoFitMergedCells and set it true to achieve your requirements.

Please see the following code and check the attached output pdf generated by it for your reference.

C#
string filePath = @“D:\Downloads\Sample.xls”;

Workbook workbook = new Workbook(filePath);

Worksheet worksheet = workbook.Worksheets[“Electrical Requirements”];

AutoFitterOptions opts = new AutoFitterOptions();
opts.AutoFitMergedCells = true;
opts.OnlyAuto = true;

worksheet.AutoFitColumns(opts);

workbook.Save(“output.pdf”);

Thanks Team for quick turnaround.

It worked for me.

Thanks again,
Shweta

Dear Shweta,

Thanks for your quick and positive feedback, we appreciate it and using Aspose.Cells.

It is good to know that your issue is now resolved. Let us know if you encounter any other issue, we will be glad to look into it and help you further.

Hi,

One point I noticed after applying the fix is that last column moved to the next page. Previously I fixed the first column width and applied text wrapping so that content gets wrapped to next line.
After setting AutoFitColumns width of first column changed based on the content. But I don’t want to change the width of the column. Is it possible to fix it without changing the width of column.

Please share your comments.

Thanks,
Shweta

Dear Shweta,

Thanks for your good observation and using Aspose.Cells.

We were able to notice this issue. When we directly convert excel to pdf using Microsoft Excel, it generates 10 pages but after converting with Aspose.Cells with the above code, it generates 19 pages and last column moves to next page. I have attached the Microsoft Excel 2010 generated pdf for a reference.

To help you provide appropriate sample code or resolve this issue by mimicking the Microsoft Excel generated pdf, we have logged this issue in our database for investigation. We will look into it and fix this issue. Once the issue is resolved or we have some other update for you, we will let you know asap.

This issue has been logged as

  • CELLSNET-43974 - Converting Excel to PDF after auto fitting merged cells makes the last column moved to next page

Hi,


Could you try our latest version/ fix: Aspose.Cells for .NET (Latest Version) if it resolves your issue.

Let us know your feedback.

Thank you.