表格字体样式、大小修改

This commit is contained in:
zhal 2023-09-07 14:50:49 +08:00
parent a0871aca8c
commit ed61d9be11
2 changed files with 17 additions and 7 deletions

View File

@ -386,6 +386,14 @@ public class OutputWordUtil {
for (int z= 0; z < rows.getCells().get(j).getParagraphs().getCount();z++){ for (int z= 0; z < rows.getCells().get(j).getParagraphs().getCount();z++){
Paragraph p = rows.getCells().get(j).getParagraphs().get(z); Paragraph p = rows.getCells().get(j).getParagraphs().get(z);
p.getFormat().setLineSpacing(12f);//设置边距为1.0 p.getFormat().setLineSpacing(12f);//设置边距为1.0
for (int k = 0; k < p.getItems().getCount(); k++) {
DocumentObject item = p.getItems().get(k);
if (item instanceof TextRange) {
TextRange textRange = (TextRange) item;
textRange.getCharacterFormat().setFontName("宋体");
textRange.getCharacterFormat().setFontSize(10.5f);
}
}
} }
} }
@ -409,7 +417,7 @@ public class OutputWordUtil {
TextRange tr2 = paragraph2.appendText("修订记录"); TextRange tr2 = paragraph2.appendText("修订记录");
tr2.getCharacterFormat().setBold(true); tr2.getCharacterFormat().setBold(true);
tr2.getCharacterFormat().setFontName("宋体"); tr2.getCharacterFormat().setFontName("宋体");
tr2.getCharacterFormat().setFontSize(12); tr2.getCharacterFormat().setFontSize(10.5f);
paragraph2.applyStyle(BuiltinStyle.Body_Text); //应用标题1样式 paragraph2.applyStyle(BuiltinStyle.Body_Text); //应用标题1样式
@ -466,9 +474,8 @@ public class OutputWordUtil {
p.getFormat().setHorizontalAlignment(Center); p.getFormat().setHorizontalAlignment(Center);
TextRange txtRange = p.appendText(header[i]); TextRange txtRange = p.appendText(header[i]);
//txtRange.getCharacterFormat().setFontName("宋体"); // 设置字体名称
txtRange.getCharacterFormat().setBold(true); txtRange.getCharacterFormat().setBold(true);
//txtRange.getCharacterFormat().setFontSize();
} }
@ -508,6 +515,7 @@ public class OutputWordUtil {
TextRange text =dataRow.getCells().get(c).addParagraph().appendText(data[r][c]); TextRange text =dataRow.getCells().get(c).addParagraph().appendText(data[r][c]);
text.getCharacterFormat().setFontName("宋体"); text.getCharacterFormat().setFontName("宋体");
text.getCharacterFormat().setFontSize(10.5f);
} }
} }
@ -710,7 +718,7 @@ public class OutputWordUtil {
TextRange tr = paragraph1.appendText("相关文件"); TextRange tr = paragraph1.appendText("相关文件");
tr.getCharacterFormat().setBold(true); tr.getCharacterFormat().setBold(true);
tr.getCharacterFormat().setFontName("宋体"); tr.getCharacterFormat().setFontName("宋体");
tr.getCharacterFormat().setFontSize(12); tr.getCharacterFormat().setFontSize(10.5f);
//tr.applyCharacterFormat(format); //应用字体格式 //tr.applyCharacterFormat(format); //应用字体格式
paragraph1.applyStyle(BuiltinStyle.Body_Text); //应用标题1样式 paragraph1.applyStyle(BuiltinStyle.Body_Text); //应用标题1样式
@ -771,7 +779,7 @@ public class OutputWordUtil {
TextRange text =dataRow.getCells().get(c).addParagraph().appendText(data[r][c]); TextRange text =dataRow.getCells().get(c).addParagraph().appendText(data[r][c]);
text.getCharacterFormat().setFontName("宋体"); text.getCharacterFormat().setFontName("宋体");
text.getCharacterFormat().setFontSize(10.5f);
} }
} }
@ -829,7 +837,7 @@ public class OutputWordUtil {
TextRange tr = paragraph1.appendText("外部相关文件"); TextRange tr = paragraph1.appendText("外部相关文件");
tr.getCharacterFormat().setBold(true); tr.getCharacterFormat().setBold(true);
tr.getCharacterFormat().setFontName("宋体"); tr.getCharacterFormat().setFontName("宋体");
tr.getCharacterFormat().setFontSize(12); tr.getCharacterFormat().setFontSize(10.5f);
//tr.applyCharacterFormat(format); //应用字体格式 //tr.applyCharacterFormat(format); //应用字体格式
paragraph1.applyStyle(BuiltinStyle.Body_Text); //应用标题1样式 paragraph1.applyStyle(BuiltinStyle.Body_Text); //应用标题1样式
@ -884,6 +892,7 @@ public class OutputWordUtil {
//dataRow.getCells().get(c).addParagraph().appendText(data[r][c]); //dataRow.getCells().get(c).addParagraph().appendText(data[r][c]);
TextRange text =dataRow.getCells().get(c).addParagraph().appendText(data[r][c]); TextRange text =dataRow.getCells().get(c).addParagraph().appendText(data[r][c]);
text.getCharacterFormat().setFontName("宋体"); text.getCharacterFormat().setFontName("宋体");
text.getCharacterFormat().setFontSize(10.5f);
} }
} }
@ -920,7 +929,7 @@ public class OutputWordUtil {
TextRange tr2 = paragraph2.appendText("支持文件"); TextRange tr2 = paragraph2.appendText("支持文件");
tr2.getCharacterFormat().setBold(true); tr2.getCharacterFormat().setBold(true);
tr2.getCharacterFormat().setFontName("宋体"); tr2.getCharacterFormat().setFontName("宋体");
tr2.getCharacterFormat().setFontSize(12); tr2.getCharacterFormat().setFontSize(10.5f);
paragraph2.applyStyle(BuiltinStyle.Body_Text); //应用标题1样式 paragraph2.applyStyle(BuiltinStyle.Body_Text); //应用标题1样式
@ -974,6 +983,7 @@ public class OutputWordUtil {
//dataRow.getCells().get(c).addParagraph().appendText(data[r][c]); //dataRow.getCells().get(c).addParagraph().appendText(data[r][c]);
TextRange text =dataRow.getCells().get(c).addParagraph().appendText(data[r][c]); TextRange text =dataRow.getCells().get(c).addParagraph().appendText(data[r][c]);
text.getCharacterFormat().setFontName("宋体"); text.getCharacterFormat().setFontName("宋体");
text.getCharacterFormat().setFontSize(10.5f);
} }
} }
Paragraph paragraph_blank = section.addParagraph(); Paragraph paragraph_blank = section.addParagraph();