gpt4 book ai didi

java - Apache POI Word XWPF 表方向和对齐方式

转载 作者:行者123 更新时间:2023-12-02 02:50:15 28 4
gpt4 key购买 nike

我想创建一个普通表格,并将其方向设置为“从右到左”“可以使用此选项设置Table Direction”,并使其对齐为“从左到右”,可以使用此选项设置Table Alignment

我已经尝试过这个:

XWPFTable myTable = myDocument.createTable();
CTTbl cttblp = myTable.getCTTbl();
CTTblPr cttblpr;
cttblpr = (cttblp.getTblPr() == null ? cttblp.addNewTblPr() : cttblp.getTblPr());

//table direction
cttblpr.addNewBidiVisual().setVal(STOnOff.ON);

//table alignment
CTJc ctjc = (cttblpr.isSetJc() ? cttblpr.getJc() : cttblpr.addNewJc());
ctjc.setVal(STJc.LEFT);

据我所知,表格方向的部分阻止了任何对齐的发生。

最佳答案

表格方向不会阻止对齐的发生,它会逆转对齐的影响。因此,在您的情况下,如果您将表格方向设置为从右到左,则必须将表格对齐方式设置为右,才能使其显示左对齐。对于具有左侧和右侧可视化的所有表格属性都是如此,例如左侧边框现在将显示在右侧,反之亦然。

参见ECMA-376 1st edition Part 4第2.4.23节第16行

If this property [jc (Table Alignment)] is omitted on a table, then the justification shall be determined by the associated table style. If this property is not specified in the style hierarchy, then the table shall be left justified with zero indentation from the leading margin (the left margin in a left-to-right table or the right margin in a right-to-left table).

ECMA-376 1st edition Part 4第 2.4.1 节第 7 行

When this property [bidiVisual (Visually Right to Left Table)] is specified, then the ordering of all cells (and table-level properties) in this table shall be applied to the table assuming that the table is a normal left to right table, but the table cells shall be displayed in a right to left direction. [Example: A left border on the first table cell shall be displayed on the right side of that cell (which would be the rightmost cell) in a visually right to left table. end example]

关于java - Apache POI Word XWPF 表方向和对齐方式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43964463/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com