表格标题字体修改,表格宽度适应

This commit is contained in:
zhal 2023-09-07 23:20:07 +08:00
parent 2692664007
commit ed183e154f
2 changed files with 6 additions and 7 deletions

View File

@ -719,7 +719,7 @@ public class OutputWordUtil {
TextRange tr = paragraph1.appendText("相关文件");
tr.getCharacterFormat().setBold(true);
tr.getCharacterFormat().setFontName("宋体");
tr.getCharacterFormat().setFontSize(10.5f);
tr.getCharacterFormat().setFontSize(12f);
//tr.applyCharacterFormat(format); //应用字体格式
paragraph1.applyStyle(BuiltinStyle.Body_Text); //应用标题1样式
@ -839,7 +839,7 @@ public class OutputWordUtil {
TextRange tr = paragraph1.appendText("外部相关文件");
tr.getCharacterFormat().setBold(true);
tr.getCharacterFormat().setFontName("宋体");
tr.getCharacterFormat().setFontSize(10.5f);
tr.getCharacterFormat().setFontSize(12f);
//tr.applyCharacterFormat(format); //应用字体格式
paragraph1.applyStyle(BuiltinStyle.Body_Text); //应用标题1样式
@ -863,7 +863,7 @@ public class OutputWordUtil {
//添加表格
Table table = section.addTable(true);
table.resetCells(data.length + 1, header.length);
table.autoFit(AutoFitBehaviorType.Auto_Fit_To_Window);
TableRow row = table.getRows().get(0);
row.isHeader(true);
row.setHeight(20);
@ -887,7 +887,6 @@ public class OutputWordUtil {
TableRow dataRow = table.getRows().get(r + 1);
dataRow.setHeight(25);
dataRow.setHeightType(TableRowHeightType.Exactly);
dataRow.getRowFormat().setBackColor(Color.white);
for (int c = 0; c < data[r].length; c++) {
dataRow.getCells().get(c).getCellFormat().setVerticalAlignment(VerticalAlignment.Middle);
//设置固定列宽
@ -933,7 +932,7 @@ public class OutputWordUtil {
TextRange tr2 = paragraph2.appendText("支持文件");
tr2.getCharacterFormat().setBold(true);
tr2.getCharacterFormat().setFontName("宋体");
tr2.getCharacterFormat().setFontSize(10.5f);
tr2.getCharacterFormat().setFontSize(12f);
paragraph2.applyStyle(BuiltinStyle.Body_Text); //应用标题1样式
@ -960,7 +959,7 @@ public class OutputWordUtil {
TableRow row = table.getRows().get(0);
row.isHeader(true);
row.setHeight(20);
//row.setHeight(20);
row.setHeightType(TableRowHeightType.Auto);
for (int i = 0; i < header.length; i++) {
row.getCells().get(i).getCellFormat().setVerticalAlignment(VerticalAlignment.Middle);
@ -978,7 +977,7 @@ public class OutputWordUtil {
//将数据添加到其余行
for (int r = 0; r < data.length; r++) {
TableRow dataRow = table.getRows().get(r + 1);
dataRow.setHeight(25);
//dataRow.setHeight(25);
dataRow.setHeightType(TableRowHeightType.Auto);
dataRow.getRowFormat().setBackColor(Color.white);
for (int c = 0; c < data[r].length; c++) {