如何在 Libre Office 平面 XML (fods) 文件中将字符串标记为粗体?



查看.fods文件中的原始XML

<table:table-column table:style-name="co1" table:default-cell-style-name="ce17"/>
<table:table-row table:style-name="ro1">
<table:table-cell table:style-name="ce15" office:value-type="string" calcext:value-type="string">
<text:p>John Smith</text:p>
</table:table-cell>
</table:table-row>
<table:table-row table:style-name="ro2">
<table:table-cell table:style-name="ce16" office:value-type="string" calcext:value-type="string">
<text:p>(123) 456-7890</text:p>
</table:table-cell>
</table:table-row>
<table:table-row table:style-name="ro2">
<table:table-cell office:value-type="string" calcext:value-type="string">
<text:p>123 Main Street</text:p>
</table:table-cell>
</table:table-row>
<table:table-row table:style-name="ro2">
<table:table-cell office:value-type="string" calcext:value-type="string">
<text:p>Anywhere, ZZ 12345-6789</text:p>
</table:table-cell>
</table:table-row>
<table:table-row table:style-name="ro1">
<table:table-cell table:style-name="ce15" office:value-type="string" calcext:value-type="string">
<text:p>Jane Doe</text:p>
</table:table-cell>
</table:table-row>
<table:table-row table:style-name="ro2">
<table:table-cell table:style-name="ce16" office:value-type="string" calcext:value-type="string">
<text:p>(234) 567-8901</text:p>

Libre Office打开时,名称以粗体显示。 这在上述XML中会反映在哪里? 我只看到一个没有粗体、下划线等标记的value-type="string"

所有内容都在一列中,因此不太确定default-cell-style-name="ce17"属性指示什么。

虽然数据源自.doc文件,但我在文件上使用Libre Office

我希望从XML中提取名称,这些名称实际上仅与电话或地址区分开来,因为它们是粗体。 我想也没有数字,但我想从电子表格中选择粗体数据。

格式信息似乎有些模糊:

格式

样式和格式控件很多,提供了许多 控制信息的显示。

页面布局由各种属性控制。这些包括 页面大小、数字格式、纸盒、打印方向、边距、 边框(及其线宽(、填充、阴影、背景、列、 打印页顺序、首页码、刻度、表格居中、最大值 脚注高度和分隔符,以及许多布局网格属性。

页眉和页脚可以定义固定高度和最小高度, 边距、边框线宽度、填充、背景、阴影和动态 间距。

特定文本、段落、拼音文本有许多属性, 节、表格、列、列表和填充。特定字符可以 有他们的字体、大小、通用字体系列名称(罗马 – 衬线, 瑞士 – 无衬线,现代 – 等宽、装饰、文字或系统(, 和其他属性集。段落可以有其垂直空间 通过"保持在一起"、"寡妇和孤儿"的属性进行控制,以及 具有其他属性,例如"首字下沉"以提供特殊 格式。该列表非常广泛;请参阅参考文献(在 特别是实际标准(了解详情。

值和格式放置在 XML 文件的不同部分中。

所以通常,你有一个"样式"部分,其中所有格式都用一个名称(style:name(定义。

在表格部分,您定义了表格,其中放置的值以及样式(由他的"table:style-name"标识(。您可以为每个单元格、整行、整列甚至整个表格定义样式。

因此,在您的情况下,您可以识别查看样式名称正在使用的粗体文本。这并不总是那么容易,因为您可以为整个列/行指定默认样式(default-cell-style-name="ce17"(,如果未定义样式,则会发生这种情况。

我开发了一个用于解析Java中的ODS文件的库,所以如果您需要灵感,可以在Github中查看它: https://github.com/miachm/SODS

最新更新