Aspose Words 去除多余的 table 高度
AsposeWords get rid of extra table height
我在尝试使用 Aspose 词 api.
摆脱我的 table 上这个额外的 space 时遇到了麻烦
难道没有使用最小值 space 并仅在文本长度达到限制时才扩展单元格高度的功能吗?
目前,我的 table 看起来像这样...
但我希望构建 table 时不使用 space,如下所示:
使用哪些属性是正确的,使用顺序是什么?
我正在用 DocumentBuilder 构建 table。
这些是我的代码:
Table table = builder.startTable();
// Insert Column headers:
int hcolumn = 0;
for (String column : columns) {
builder.insertCell();
builder.getFont().setBold(true);
builder.getRowFormat().setHeadingFormat(true);
builder.writeln(translateHeader(column, hcolumn));
table.setBottomPadding(0);
hcolumn++;
}
builder.endRow(); // End of Header
builder.getRowFormat().clearFormatting();
// Loop through the records, split comma seperated(per cell) and create
// a "row" for each loop.
for (String string : data) {
List<String> result = Arrays.asList(string.split("\s*,\s*"));
int column = 0;
for (String string2 : result) {
builder.insertCell();
builder.getFont().setBold(false);
builder.getRowFormat().setHeadingFormat(false);
// translate and insert
builder.writeln(translateData(string2, column));
column++;
}
builder.endRow();
}
builder.endTable();
我将 "setBottomPadding" 添加到 0,但没有帮助。
根据文档,DocumentBuilder.WriteLn
这样做:在文档中插入一个字符串和一个段落;所以你只想在没有段落中断的情况下写入数据。尝试使用 builder.write
而不是 builder.writeln
并查看它是否有效。
PS:大家可能已经知道了,但是write[ln]
后面的ln
代表的是line
,所以一般表示会print/write 在 text/data.
末尾添加新行
将builder.writeln(translateData(string2, column));
替换为builder.write(translateData(string2, column));
writeln
在底部添加一个 space(新行)。
我在尝试使用 Aspose 词 api.
摆脱我的 table 上这个额外的 space 时遇到了麻烦难道没有使用最小值 space 并仅在文本长度达到限制时才扩展单元格高度的功能吗?
目前,我的 table 看起来像这样...
但我希望构建 table 时不使用 space,如下所示:
使用哪些属性是正确的,使用顺序是什么?
我正在用 DocumentBuilder 构建 table。
这些是我的代码:
Table table = builder.startTable();
// Insert Column headers:
int hcolumn = 0;
for (String column : columns) {
builder.insertCell();
builder.getFont().setBold(true);
builder.getRowFormat().setHeadingFormat(true);
builder.writeln(translateHeader(column, hcolumn));
table.setBottomPadding(0);
hcolumn++;
}
builder.endRow(); // End of Header
builder.getRowFormat().clearFormatting();
// Loop through the records, split comma seperated(per cell) and create
// a "row" for each loop.
for (String string : data) {
List<String> result = Arrays.asList(string.split("\s*,\s*"));
int column = 0;
for (String string2 : result) {
builder.insertCell();
builder.getFont().setBold(false);
builder.getRowFormat().setHeadingFormat(false);
// translate and insert
builder.writeln(translateData(string2, column));
column++;
}
builder.endRow();
}
builder.endTable();
我将 "setBottomPadding" 添加到 0,但没有帮助。
根据文档,DocumentBuilder.WriteLn
这样做:在文档中插入一个字符串和一个段落;所以你只想在没有段落中断的情况下写入数据。尝试使用 builder.write
而不是 builder.writeln
并查看它是否有效。
PS:大家可能已经知道了,但是write[ln]
后面的ln
代表的是line
,所以一般表示会print/write 在 text/data.
将builder.writeln(translateData(string2, column));
替换为builder.write(translateData(string2, column));
writeln
在底部添加一个 space(新行)。