当fo:table-cell 中的column-number 属性的值由于与先前单元格的number-columns-spanned 或number-rows-spanned 冲突而无法遵守时,将引发此异常。
单元格跨列导致的错误
让我们看看这个简单的例子,它显示了一个有 3 列和 1 行的表,它会产生相同类型的错误:
<fo:table>
<fo:table-column column-number="1"/>
<fo:table-column column-number="2"/>
<fo:table-column column-number="3"/>
<fo:table-body>
<fo:table-row>
<fo:table-cell column-number="1">
<fo:block>a</fo:block>
</fo:table-cell>
<fo:table-cell column-number="2" number-columns-spanned="2">
<fo:block>b</fo:block>
</fo:table-cell>
<fo:table-cell column-number="3">
<fo:block>c</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>
- 第一个细胞是正常细胞
- 第二个单元格跨越两列,因此它占据了第 2 列和第 3 列
- 但是有另一个单元格,声称在第 3 列 -> 第二个和第三个单元格在第 3 列重叠
单元格跨行导致的错误
如果存在跨越多行的单元格,可能会发生类似的情况,并与以下行中的单元格冲突:
<fo:table>
<fo:table-column column-number="1"/>
<fo:table-column column-number="2"/>
<fo:table-body>
<fo:table-row>
<fo:table-cell column-number="1" number-rows-spanned="2">
<fo:block>A</fo:block>
</fo:table-cell>
<fo:table-cell column-number="2">
<fo:block>B</fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell column-number="1">
<fo:block>C</fo:block>
</fo:table-cell>
<fo:table-cell column-number="2">
<fo:block>D</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>
这里的冲突单元格是第 1 行的第一个单元格和第 2 行的第一个单元格。
结论
我建议检查您的 FO 文件或创建它的代码(可能是 XSLT?)以查找具有 number-columns-spanned 或 number-rows-spanned 的单元格,然后(在存在冲突的情况下)删除这些属性或冲突的单元格。
在 pdf 中,表格是正确的。
这非常奇怪,因为这个异常的严重性(至少在 FOP 1.1 中)是致命的,即程序异常终止。
我认为,如果确实创建了一个 pdf 文件,则有可能不正确的表格已被错误完全“吞噬”,因此您的输出可能会丢失某些部分。