我有几个odt文件,我想将它们合并成一个新的文件。
我正在使用拉托里奥库来读取odt文件。
from relatorio.templates.opendocument import Template
from os.path import dirname, join
odt_1 = Template(source='', filepath='report_test_1_fulled.odt')
odt_2 = Template(source='', filepath='report_test_2_fulled.odt')为了将它们合并为一个,我尝试了两种选择,但没有成功:
pip install aspose-words时,我会得到以下错误:ERROR: Could not find a version that satisfies the requirement aspose-words (from versions: none)
ERROR: No matching distribution found for aspose-words我认为这可能是因为我的计算机操作系统是macOS Catalina,而这并不能完全实现要求。
有什么建议吗?最后的目标是最终得到一个包含两者的.odt或.docx。
发布于 2022-11-08 20:16:19
要使用Aspose.Words组合两个文档,可以使用文档方法。
dstDoc = aw.Document("documentA.odt")
srcDoc = aw.Document("documentB.odt")
# Append the source document to the destination document.
# Pass format mode to retain the original formatting of the source document when importing it.
dstDoc.append_document(srcDoc, aw.ImportFormatMode.KEEP_SOURCE_FORMATTING)
dstDoc.save("out.odt")您可以在这里了解有关附加和插入文档的更多信息:https://docs.aspose.com/words/python-net/insert-and-append-documents/
PS:您说得对,目前Aspose.Words for Python不支持MacOS。
https://stackoverflow.com/questions/74363396
复制相似问题