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;
}
}
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:
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.
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.
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.
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);
}
}
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!
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.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.