Open DigitalPlatform opened 2 years ago
这是一个容器元素,里面包含一个或者多个 style 元素,用来定义各种样式。 styles 元素的位置要放在根元素下级。
定义样式。具有如下属性:
name 样式名。
baseOn 基于何种样式。这里是一个已经存在的其它样式名。
font 字体名列表。如 ascii:Times New Roman,eastAsia:宋体
。其中 ascii 子参数表示 ASCII 字符的字体名;eastAsia 子参数表示东亚(中日韩)字符的字体名。此外还可以用子参数 hAnsi 和 cs,分别表示“高位 ANSI 字符”和“复杂脚本”。
size 字体尺寸。如 24pt
。可以使用的度量单位有 pt,表示“点”,即 1/72 英寸,这是一种传统排版常用的尺寸单位。如果属性值中缺乏度量单位(只有纯数值),那么等于 pt 单位。此外还可以用下列单位:hps(二分之一点)。
style 字体风格。如 bold,italic
。分别表示粗体和斜体。可以单独使用也可以组合使用。
定义边框特性。位于 style 元素之下。
border 元素下通过 top bottom left right between 元素定义上、下、左、右、之间的边框特性。这几个元素都有下列属性:
value 定义边框样式,可用值见后表; size 定义边框厚度。单位为 pt。最小值 0.25pt,最大值 12pt; space 定义边框内边沿的厚度。单位为 pt; color 定义边框颜色。值为 "00FF00" 这样的形态。
single - a single line dashDotStroked - a line with a series of alternating thin and thick strokes dashed - a dashed line dashSmallGap - a dashed line with small gaps dotDash - a line with alternating dots and dashes dotDotDash - a line with a repeating dot - dot - dash sequence dotted - a dotted line double - a double line doubleWave - a double wavy line inset - an inset set of lines nil - no border none - no border outset - an outset set of lines thick - a single line thickThinLargeGap - a thick line contained within a thin line with a large-sized intermediate gap thickThinMediumGap - a thick line contained within a thin line with a medium-sized intermediate gap thickThinSmallGap - a thick line contained within a thin line with a small intermediate gap thinThickLargeGap - a thin line contained within a thick line with a large-sized intermediate gap thinThickMediumGap - a thick line contained within a thin line with a medium-sized intermediate gap thinThickSmallGap - a thick line contained within a thin line with a small intermediate gap thinThickThinLargeGap - a thin-thick-thin line with a large gap thinThickThinMediumGap - a thin-thick-thin line with a medium gap thinThickThinSmallGap - a thin-thick-thin line with a small gap threeDEmboss - a three-staged gradient line, getting darker towards the paragraph threeDEngrave - a three-staged gradient like, getting darker away from the paragraph triple - a triple line wave - a wavy line
这是一个容器元素,里面包含一个或者多个 column 元素,用来定义页面多栏效果。columns 元素也可以单独使用(多栏等宽的情况)。 columns 元素的位置要放在根元素下级。
具有如下属性: columnCount 栏数。 separator 栏间是否有竖线?为"true" 和 "false" 之一。 space 栏之间的间隔宽度。默认度量单位为 pt(点)。还可以使用下列度量单位:dxa(二十分之一点)。 equalWidth 多栏之间是否宽度相等?为"true"和"false"之一。
当 equalWidth 属性值为 "true" 时,columns 元素下级不需要使用 column 元素;否则需要使用 column 元素,有多少个栏目就要有多少个 column 元素。
定义多栏中的一个栏目。 具有如下属性: width 栏宽度。默认度量单位为 pt(点),还可以使用 dxa(二十分之一点)。 space 本栏和下一个栏之间的间隔。默认度量单位为 pt(点),还可以使用 dxa(二十分之一点)。
这是一个容器元素,里面包含一个或者多个 header 元素,用来定义页眉。 headers 元素的位置要放在根元素下级。
定义一个页眉。 header 元素下可以包含 p 元素,和普通段落用法相同。 此外,还可以包含 pageNumber 元素和 pageCount 元素,分别表示当前页码和总页数。
这是一个容器元素,里面包含一个或者多个 footer 元素,用来定义页脚。 footers 元素的位置要放在根元素下级。
参考 header 元素用法。
表示一个文本自然段。 具有如下属性: style 样式名。引用一个已经定义好的 style 元素的 name 属性值。 alignment 对齐方式。可用值:left(左) center(中) right(右) both(两端) start(开始) end(结束) mediumKashida distribute numTab highKashida lowKashida thaiDistribute。 pageBreakBefore 段落前分页。缺省为 "false"。
定义一个表格。table 元素下需要使用若干 tr 元素来定义表格行。
具有如下属性:
width 表格宽度。可以使用的度量单位:pt(点) dxa(二十分之一点) %
(百分比)。默认 pt。属性值如果为 "auto",则表示软件自动决定宽度。
cellMarginDefault 表格单元的外边沿空白宽度。为四个值用逗号间隔,例如 "0,10,0,0",分别表示左、上、右、下边沿的空白宽度。每个值可以使用的度量单位:pt(点) dxa(二十分之一点),默认 pt。
layout 表格布局。为 "fixed" 和 "autofit" 之一,分别表示固定栏目宽度布局和自动填充布局。缺省相当于 "autofit"。
表示一个表格行。tr 元素下需要使用若干 td 元素或 th 元素来定义表格单元。
具有如下属性: cantSplit 跨页的时候本表格行不分割。缺省为 "false",表示要分割。"true" 表示不分割。
表示一个表格单元。td 元素下需要用一个或多个 p 元素来表示文本段落。或者直接使用文本。
具有如下属性:
width 本单元宽度。可以使用的度量单位:pt(点) dxa(二十分之一点) %
(百分比) cm(厘米)。默认 pt。属性值如果为 "auto",则表示软件自动决定宽度。
noWrap (单元特性)单元内文字是否不折行。"true" 表示文字不折行。缺省为"false"。
style 单元格风格。值为所引用的风格名字,或者 "."。点表示使用内嵌的 style 元素。
表示一个表格栏标题单元。th 元素下需要用一个或多个 p 元素来表示文本段落。或者直接使用文本。
具有如下属性:
width 本单元宽度。可以使用的度量单位:pt(点) dxa(二十分之一点) %
(百分比)。默认 pt。属性值如果为 "auto",则表示软件自动决定宽度。
<p alignment='right'>文字</p>
<p style='.'>
<style alignment='right'/>
文字
</p>
注:要和 <p><style>text</style></p>
用法区别开
<styles>
<style name='test_style' alignment='right' />
</styles>
<p style='test_style'>文字</p>
<p style='.'>段落文字
<style>
<border>
<top value="single" size="2" space="1" color="FF0000" />
<left value="single" size="2" space="1" color="FF0000" />
<bottom value="single" size="2" space="1" color="00FF00" />
<right value="single" size="2" space="1" color="FF0000" />
<between value="single" size="4" space="2" color="4D5D2C" />
</border>
</style>
</p>
<styles>
<style name='test_style' alignment='left' >
<border>
<top value="single" size="2" space="1" color="FF0000" />
<left value="single" size="2" space="1" color="FF0000" />
<bottom value="single" size="2" space="1" color="00FF00" />
<right value="single" size="2" space="1" color="FF0000" />
<between value="single" size="4" space="2" color="4D5D2C" />
</border>
</style>
</styles>
<p style='test_style'>段落文字</p>
<table>
<tr>
<td style='.'>表格单元文字
<style>
<border>
<top value="single" size="2" space="1" color="FF0000" />
<left value="single" size="2" space="1" color="FF0000" />
<bottom value="single" size="2" space="1" color="00FF00" />
<right value="single" size="2" space="1" color="FF0000" />
<between value="single" size="4" space="2" color="4D5D2C" />
</border>
</style>
</td>
</tr>
</table>
<styles>
<style name='test_style' type='td'>
<border>
<top value="single" size="2" space="1" color="FF0000" />
<left value="single" size="2" space="1" color="FF0000" />
<bottom value="single" size="2" space="1" color="00FF00" />
<right value="single" size="2" space="1" color="FF0000" />
<between value="single" size="4" space="2" color="4D5D2C" />
</border>
</style>
</styles>
<table>
<tr>
<td style='test_style'>表格单元文字</td>
</tr>
</table>
当第一个 tr 中的 td 数量不足时(因为 td 中用了 colspan 的缘故),需要在 table 元素内使用 tableGrid 元素。
<table>
<tableGrid>
<gridColumn gridWidth='23'/>
<gridColumn gridWidth='23'/>
<gridColumn gridWidth='23'/>
</tableGrid>
<tr>
<td colspan='2'>11</td>
<td>13</td>
</tr>
<tr>
<td>21</td>
<td>22</td>
<td>23</td>
</tr>
</table>
注1:如果 table 元素以内没有出现 tableGrid 元素,则会自动采用第一个 tr 中的 td 或者 th 元素,数它们的个数来自动产生 tableGrid/gridColumn 元素
注2: 为了兼容 WPS,gridColumn 元素必须具备 gridWidth 属性,属性值可以随意填写一个。
为了最终输出为 docx 格式,特设计了本排版中间格式。目的是降低输出模块直接创建 docx 结构的难度。
这种中间格式是一种 XML 格式。样例如下: