Excel转换PDF,抛出Shape to image Error的异常,导致转换失败
附件为:
EXCEL_TEST.zip (9.0 MB)
Aspose.cells 版本 25.0.6
Cause
The error “Shape to image Error!” during the conversion of Excel to PDF typically occurs due to issues with rendering shapes or images in the Excel file. This can happen if the shapes are complex or if there are unsupported formats.
Solution
To resolve this issue, use the PdfSaveOptions.IgnoreError
property, which allows the conversion process to continue even if there are errors related to shapes or images. However, be aware that this may lead to some data loss, as problematic shapes might not be rendered in the output PDF.
Code
Here’s a sample code snippet to implement this solution:
import com.aspose.cells.*;
public class ExcelToPdfConversion {
public static void main(String[] args) {
// Load the Excel file
Workbook workbook = new Workbook("path/to/your/excel/file.xlsx");
// Create PdfSaveOptions and set IgnoreError to true
PdfSaveOptions pdfSaveOptions = new PdfSaveOptions();
pdfSaveOptions.setIgnoreError(true);
// Save the workbook to PDF
workbook.save("output.pdf", pdfSaveOptions);
}
}
Next Steps
If you have any further questions or need additional assistance, please feel free to ask!
The images in the Excel file are critical in most cases, as it is SOP for our operators. So we cannot ignore the data loss, paticularly not being aware of it
@cromwell1994
通过使用样例文件和以下样例代码在最新版本v25.6上进行测试,我们可以复现问题。当转换excel文件到pdf时, 出现图形转换报错异常:“Aspose.Cells.CellsException: Shape to image Error!”。
Workbook workbook = new Workbook(filePath + "NA593831_MI SOP_20250707.xlsx");
workbook.Save(filePath + "out_net.pdf");
我们已经在内部问题跟踪系统中打开了以下新问题单,并将根据Free Support Policies中提到的条款提供修复。
问题单号:CELLSNET-58716
@cromwell1994
您的问题 ( CELLSNET-58716) 已解决,修复后的功能将随版本 25.7 发布。
以下是使用最新函数生成的结果文件:
CELLSNET-58716.pdf (7.0 MB)
The issues you have found earlier (filed as CELLSNET-58716) have been fixed in this update. This message was posted using Bugs notification tool by leoluo