我在尝试使用 aspose Words api 消除表格上的额外空间时遇到问题。
是否有一个函数可以仅在文本长度达到限制时使用最小空间并扩展单元格高度?
目前,我的 table 看起来像这样......
但我希望构建的表格没有空格,如下所示:
什么是正确的属性以及使用顺序?
我正在用 DocumentBuilder 构建表格.
这是我的代码:
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
,所以它通常意味着它将打印/写入在文本/数据末尾添加新行。
关于java - AsposeWords 摆脱额外的表格高度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45323541/