我一直在寻找答案,但到目前为止没有任何帮助。我有一个方法,我想用它来创建一个 odt 文件并用文本填充它。我还希望用户在创建文件时查看它。我正在使用 python 3.4.3 unotools 0.3.3 LinuxMint 17.1 LibreOffice 4.2.8.2
问题:
unotools.errors.ConnectionError: failed to connect: ('socket,host=localhost,port=8100', {})
unotools 示例在终端上运行良好 - 创建并保存了一个 sample.odt,没有错误。我的草稿代码:
def writer_report(self):
subprocess.Popen(["soffice", "--accept='socket,host=localhost,port=8100;urp;StarOffice.Service'"])
time.sleep(5) # using this to give time for LibreOffice to open - temporary
context = connect(Socket('localhost', '8100'))
writer = Writer(context)
writer.set_string_to_end('world\n')
writer.set_string_to_start('hello\n')
writer.store_to_url('output.odt','FilterName','writer8')
writer.close(True)
LibreOffice 应用程序打开并保持打开状态。但是,连接似乎丢失了。
我希望有人可以给我帮助,谢谢。