Complete text not visible on Conversion from Excel to PDF

Hello,

We have a requirement where we need to fill large text in a single cell of excel. The number of lines in that single cell are increasing than the maximum row height allowed (409.5) by microsoft excel. In such a scenario, when the excel gets generated(even after using autofit row feature) the text is visible only till the maximum row height and the remaining text gets hidden. We can see all the data when we open the excel in edit mode and double click on that particular cell with large data. But the complete text is not visible in the pdf which we are generating directly from the excel. Only the text till the maximum row height gets displayed in the pdf. The remaining hidden data gets missed out in the pdf. We have used the below code to generate the excel:

final PdfSaveOptions saveOptions = new PdfSaveOptions(SaveFormat.PDF);


saveOptions.setAllColumnsInOnePagePerSheet(true);


try {


final AutoFitterOptions fitterOptions = new AutoFitterOptions();


fitterOptions.setAutoFitMergedCells(true);


afifWorkbook.getWorkbook().getWorksheets().get(0).autoFitRows(fitterOptions);


afifWorkbook.getWorkbook().save(response.getOutputStream(),saveOptions);


} catch (final IOException e) {


throw new FIFException(“IOError while trying to save excel file to the output stream”,e);


} catch (final Exception e) {


throw new FIFException(“Exception while trying to save excel file to the output stream”,e);


}

I have attached the sample excel and pdf file for your reference. (Check row 158 in the excel and page 5 in the pdf).

Please let us know if there is any exisitng way to fix this issue using aspose.cells

Thanks and Regards,

Bhakti


Hi Bhakti,


Thank you for contacting Aspose support.

First of all, please note that Aspose.Cells APIs follow Excel’s guidelines and recommendations in its implementation. Therefore any restriction imposed by Excel application will surely be applicable while using Aspose.Cells.

That being said, in this scenario Excel application imposes the restriction on the row height so you cannot exceed it while using Aspose.Cells APIs. The cell A158 from your provided spreadsheet contains the text that cannot fit the maximum row height so it would be cut-off while rendering the spreadsheet to PDF format. You may check the behavior with Excel application, and you will notice that the PDF generated with Aspose.Cells for Java renders the part of text exactly the same as of Excel generated PDF.

One workaround to this situation could be to increase the column width to a size that could accommodate the text completely. You may retrieve the existing column width using the Cells.getColumnWidth method (or its variations) and add some more to it using the Cells.setColumnWidth method. Alternatively, You may also merge the said cell with it’s right neighbor to create a bigger cell. Please check the article on merging cells for your reference.