Excel to PDF conversion - Unable to create a PDF using Aspose.Cells for a certain number of records

Hi Team,

We are trying to create a PDF using an excel. This excel contains table data which varies daily. when we have 93 to 97 rows in excel the pdf is getting created but not opening.

Below is the code we are using to create the PDF.

def autoSizeColumns(worksheet:Worksheet) {
val a:Int = worksheet.getCells.getMaxDataColumn()
for(colNum <- 1 to a){
worksheet.getCells.setColumnWidth(colNum,worksheet.getCells.getColumnWidth(colNum) + 5)}
}
val workbook = new Workbook("/dbfs/mnt/input/SCB.xlsx")
val pdfSaveOptions = new PdfSaveOptions
val worksheet:Worksheet = workbook.getWorksheets.get(0)
worksheet.autoFitColumns
worksheet.autoFitRows
autoSizeColumns(worksheet)
pdfSaveOptions.setAllColumnsInOnePagePerSheet(true)
pdfSaveOptions.setCalculateFormula(true)
workbook.save(s"/dbfs/mnt/output/a.pdf", pdfSaveOptions)

Please let us know the solution for this.

@VamsiKrish,

Please zip and attach your template Excel file “SCB.xlsx”, current output PDF by Aspose.Cells for Java and your desired output PDF file. We will check your issue soon.

Hi Amjad,

I have attached the input excel file with 100 rows. I am able to create pdf till 93 rows after that it is failing. Please find the attached zip file.Files.zip (57.9 KB)

@VamsiKrish,
We have tried this scenario using the latest version Aspose.Cells for Java 21.7.x but could not observe this issue. Could you please try the following sample code with the latest version and share your feedback.

Workbook workbook = new Workbook("ExcelToPDFTesting.xlsx");
PdfSaveOptions options = new PdfSaveOptions();
options.setAllColumnsInOnePagePerSheet(true);
workbook.save("ExcelToPDFTesting.pdf", options);

ExcelToPDFTesting.pdf.zip (65.6 KB)

Hi,

I have tried above code to generate the pdf but I got the pdf but it is not opening. I am attaching it here. ExcelToPDFTesting.pdf (33.7 KB)

After using above code I got the below error but the pdf is generated.
–com.aspose.cells.CellsException: No such file or directory

we are using Scala 2.11 and aspose 21.7 for this. Please check and let us know for the solution

@VamsiKrish,
The code is working ok on our side. Please check if the file paths are correct while loading and saving the files.