Failed to transform excel to PDF

Hi,

We are trying to transform attached excel file to PDF using Aspose 24.8.
It’s throwing the below error.

Exception in thread “main” com.aspose.cells.CellsException: For input string: “22860100000”
at com.aspose.cells.cxv.a(Unknown Source)
at com.aspose.cells.kk.a_(Unknown Source)
at com.aspose.cells.Workbook.a(Unknown Source)
at com.aspose.cells.Workbook.save(Unknown Source)
at com.aspose.cells.Workbook.save(Unknown Source)
at com.aspose.test.AsposeTest.main(AsposeTest.java:72)

Please find the sample code.

public class AsposeTest {
    public static void main(String args[]) throws Exception {
      com.aspose.cells.Cell firstCell = null;
        com.aspose.cells.Workbook doc2 = new com.aspose.cells.Workbook("C:\\IA.xlsx");
        if (null != doc2 && doc2.getWorksheets().getCount() > 1) {
            Worksheet workSheet = getFirstActiveSheet(doc2);
            firstCell = getBookmarkCell(workSheet);
        }

        ArrayList list = new ArrayList();
        Cell cell = null;
        PdfBookmarkEntry subBookmarks = null;
        for (int i = 0; i < doc2.getWorksheets().getCount(); i++) {
            //Create bookmarks for PDF
                cell = getBookmarkCell(doc2.getWorksheets().get(i));
                subBookmarks = new PdfBookmarkEntry();
                subBookmarks.setText(doc2.getWorksheets().get(i).getName());
                subBookmarks.setDestination(cell);

                list.add(subBookmarks);
        }
        doc2.save("C:\\IAOutput.pdf");

    }

    private static Worksheet getFirstActiveSheet(Workbook workbook) {
        Worksheet worksheet = null;
        for (int i = 0; i < workbook.getWorksheets().getCount(); i++) {
            if(workbook.getWorksheets().get(i).isSelected()) {
                worksheet = workbook.getWorksheets().get(i);
                break;
            }
        }
        return worksheet;
    }

    private static Cell getBookmarkCell(Worksheet worksheet) {
        Cell cell = worksheet.getCells().get(0, 0);
        com.aspose.cells.PageSetup pageSetup = worksheet.getPageSetup();
        String printArea = pageSetup.getPrintArea();
        if(printArea != null) {
            cell = worksheet.getCells().createRange(printArea).get(0, 0);
        }
        return cell;
    }
}


Please find the attached excel file.

Testing_file.zip (7.5 KB)

Regards,
Pavan

@rnara

It seems that you are encountering a CellsException when trying to convert an Excel file to PDF using Aspose.Cells. The error message indicates that there is an issue with the input string “22860100000”. This could be related to how the data in your Excel file is formatted or how Aspose.Cells is interpreting it.

Here are a few steps you can take to troubleshoot and potentially resolve the issue:

  1. Check Data Types: Ensure that the cell containing “22860100000” is formatted correctly in Excel. If it’s meant to be a number, make sure it is not formatted as text. You can do this by selecting the cell in Excel, right-clicking, choosing “Format Cells,” and selecting the appropriate number format.

  2. Update Aspose.Cells: You are using version 24.8 of Aspose.Cells. If possible, consider updating to the latest version, as there may have been bug fixes or improvements related to data handling in newer releases.

  3. Simplify the Workbook: If the issue persists, try creating a simplified version of your Excel file with just the problematic data. This can help isolate the issue and determine if it’s related to specific content or formatting in your original file.

  4. Use PdfSaveOptions: When saving the workbook to PDF, you can specify options that might help with the conversion. For example, you can set PdfSaveOptions to control how the PDF is generated. Here’s a simple example of how to use PdfSaveOptions:

    import com.aspose.cells.PdfSaveOptions;
    import com.aspose.cells.Workbook;
    
    public class ExcelToPDF {
        public static void main(String[] args) throws Exception {
            Workbook workbook = new Workbook("C:\\IA.xlsx");
            PdfSaveOptions options = new PdfSaveOptions();
            // Set options as needed
            workbook.save("C:\\IAOutput.pdf", options);
        }
    }
    
  5. Review Documentation: For more detailed guidance on converting Excel files to PDF, you can refer to the official Aspose documentation or examples available on their GitHub repository.

If you continue to experience issues, consider sharing a minimal reproducible example or more details about the content of your Excel file for further assistance.

Feel free to reach out if you have any more questions or need additional help!

Sources:
[1]: Excel to PDF Conversion Example

@Professionalize.Discourse ,

We analyzed the excel file. If we remove below arrow from excel file, it is working fine.

image.png (1.3 KB)

Could you please help us understand why this arrow create an issue with xlsx format ?

Regards,
Pavan

@rnara,

Thanks for the template file and details.

After initial testing, I am able to reproduce the issue as you mentioned by using your template file. I found "com.aspose.cells.CellsException: For input string: “22860100000"” when rendering Excel file to PDF.

We require thorough evaluation of the issue. We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): CELLSJAVA-46288

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

@rnara
Your issue( CELLSJAVA-46288) has been resolved and the fixed functionality will be released with version 25.3.

The issues you have found earlier (filed as CELLSJAVA-46288) have been fixed in Aspose.Cells for Java 25.3.