是否可以从与HTML和CSS构建网页相似的代码中构建Libreoffice文档?
是否可以从与HTML和CSS构建网页相似的代码中构建Libreoffice文档?一个人可以编写一个ODF文件,其中内容和样式是分开的,然后在libreoffice中打开/查看?如果是这样,一个人可以像为HTML/CSS完成的文本编辑器中编写代码吗?
我现在要问的两个原因。 1)当我需要在libreoffice中进行风格更改时,我必须在一百个地方手动进行相同的调整,例如改变块引号的风格。 2)我想从文本数据库构建文档。
我找到了一个问题与数据库有关,但大约八年了。
感谢您可能提供的任何方向。
Is it possible to build a LibreOffice document from code similar to the way a web page is built from HTML and CSS? Can one write an ODF file in which the content and styling are separate, and then/view open in LibreOffice? If so, can one write the code in a text editor as done for HTML/CSS?
There area two reasons I now ask. 1) When I need to make a style change in LibreOffice I have to manually make the same adjustments in a hundred places, such as changing the style of block quotes. 2) I'd like to build documents from a database of text.
I found a question on this in relation to databases but it was about eight years old.
Thank you for any direction you may be able to provide.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
解压缩一个
.odt
包含样式的文件。您将看到两个文件,content.xml
和styles.xml
。使用文本编辑器编辑这些文件,然后将文件夹缩回以获取修改后的.odt
文件。请注意,XML文件中有两种样式。命名样式是大多数人认为样式的样式,而自动样式是自定义格式的,例如当您选择一些文本并直接更改字体时。
Tohuwawohu的链接描述了与文件一起编程工作的实用程序。另外,如链接中所述,自己编写代码并不难。例如,在python中,导入内置库
zipfile
和xml.etree
。Unzip an
.odt
file that contains styles. You will see two files,content.xml
andstyles.xml
. Edit these files using a text editor and then zip the folder back up to get a modified.odt
file.Be aware that there are two types of styles in the XML files. Named styles are what most people think of as styles, whereas automatic styles are custom formatting, like when you select some text and change the font directly.
The link from tohuwawohu describes utilities to work programmatically with the file. Also as mentioned in the link, it's not too hard to write code yourself. For example in python, import the built-in libraries
zipfile
andxml.etree
.