将带有图像和图表的 XLS 转换为 PDF
Contents
[
Hide
]
Aspose.Cells 支持将包含图像和图表的 XLS 文件转换为 PDF 文档。 Aspose.Cells for Java 可以独立工作,将电子表格转换为 PDF: Aspose.PDF 转换不需要 API。
该过程可以在内存中完成,因为该过程不依赖于临时或中间 XML 文件。这意味着可以快速高效地转换大型 Excel 文件,例如包含图像、图表和其他绘图对象的文件。
如果电子表格包含公式,最好调用[工作簿.计算公式](https://reference.aspose.com/cells/java/com.aspose.cells/workbook#calculateFormula()方法就在渲染到 PDF 之前。这样做可以确保重新计算公式相关值,并在 PDF 中渲染正确的值。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(ConvertXLSFileToPDF.class); | |
//Create a new Workbook | |
Workbook book = new Workbook(dataDir + "SampleInput.xlsx"); | |
//Save the excel file to PDF format | |
book.save(dataDir + "output.pdf", SaveFormat.PDF); |