将带有图像或图表的XLS文件转换为PDF
Contents
[
Hide
]
Aspose.Cells for Python via .NET支持将包含图像和图表的XLS文件转换为PDF文档。 Aspose.Cells for Python via .NET API可以独立工作,将电子表格转换为PDF:不需要Aspose.PDF for .NET进行转换。此过程可以在内存中完成,因为该过程不依赖于临时或中间XML文件。这意味着可以快速高效地转换大型Excel文件,例如包含图像、图表和其他绘图对象的文件。
示例代码
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
from aspose.cells import SaveFormat, Workbook | |
# For complete examples and data files, please go to https:# github.com/aspose-cells/Aspose.Cells-for-.NET | |
# The path to the documents directory. | |
dataDir = RunExamples.GetDataDir(".") | |
try: | |
# Get the template excel file path. | |
designerFile = dataDir + "SampleInput.xls" | |
# Specify the pdf file path. | |
pdfFile = dataDir + "Output.out.pdf" | |
# Open the template excel file | |
wb = Workbook(designerFile) | |
# Save the pdf file. | |
wb.save(pdfFile, SaveFormat.PDF) | |
except Exception as e: | |
print(str(e)) | |
input() |
如果电子表格包含公式,最好在呈现到PDF之前调用Workbook.calculate_formula方法。这样做可以确保公式相关的值被重新计算,并且在PDF中呈现正确的值。