使用OOXML设置TableRow高度

时间:2018-07-12 09:15:20

标签: openxml

我想在OOXML中设置表格行的高度
以下是我的代码

TableRow rowHeader = new TableRow();
TableRowProperties rowProperties =新的TableRowProperties();
TableRowHeight tableRowheight =新的TableRowHeight();
tableRowheight.Val = 100;
rowProperties.Append(tableRowheight);
rowHeader.Append(rowProperties);

但是它不起作用,有人可以建议。

1 个答案:

答案 0 :(得分:0)

我不知道您使用的是哪个API,但是基于对ISO 29500-1(具体为17.4.80秒)的阅读,存在两个潜在的问题:

  • val属性以“ Twips”(点的二十分之一)为单位。所以您的行高是5点,这非常小。
  • trHeight元素还有第二个(可选)属性,称为hRule。它可以具有值autoatLeastexactly。如果未指定hRule,则其值默认为autoauto表示行高是根据内容的高度自动确定的,并且val属性是无用的(在您的情况下就是这样)。

要修复此问题,请指定hRuleatLeastexact,然后适当设置高度,并注意单位。