Hi
When we convert Excel with pivot table to Pdf, vertical alignment of some cells text changes. Native excel convertion works fine.
That behavior reproduces at Конвертируйте XLSM в PDF онлайн бесплатно and in code with latest Aspose.Cells.
Pivot table:
pivot-table.png (20.7 KB)
How it converts in Excel:
excel.pdf.png (31.7 KB)
How it converts in Aspose:
aspose.pdf.png (29.0 KB)
book.xlsm, aspose.pdf, excel.pdf:
book.zip (625.7 KB)
Sample code:
var loadOptions = new LoadOptions(FileFormatUtil.DetectFileFormat(filename).LoadFormat);
loadOptions.DefaultStyleSettings.VerticalAlignment = TextAlignmentType.Bottom;
using var workbook = new Workbook(filename, loadOptions);
var saveOptions = new PdfSaveOptions();
var resultFilename = Path.ChangeExtension(filename, ".pdf");
workbook.Save(resultFilename, saveOptions);
@directum,
Thanks for the sample file and screenshots.
Please notice, after an initial test, I am able to reproduce the issue as you mentioned by using your sample file. I found an issue regarding wrong vertical alignment of the cell text on converting to PDF from Excel file with pivot table. I have logged a ticket with an id “CELLSNET-51595” for your issue. We will look into it soon.
Once we have an update on it, we will let you know.
@directum,
This is to inform you that your issue has been resolved now. The fix will be included in the next release (Aspose.Cells v22.8 ) which is scheduled in the second week of August 2022. You will also be notified when the next version is released.
The issues you have found earlier (filed as CELLSNET-51595) have been fixed in this update. This message was posted using Bugs notification tool by johnson.shi
With presented snippet now works fine.
But without
loadOptions.DefaultStyleSettings.VerticalAlignment = TextAlignmentType.Bottom;
cells with Bottom vertical alignment converts like with Center vertical alignment.
Is it normal that property DefaultStyleSettings.VerticalAlignmentof must be assigned for properly convertion?
@directum,
Yes, it is normal and your understanding it correct. You need to use the line:
loadOptions.DefaultStyleSettings.VerticalAlignment = TextAlignmentType.Bottom;
to load the file with (bottom) vertical alignment for cells which you require.