月报整合导出--设置字体
This commit is contained in:
+15
-18
@@ -546,11 +546,12 @@ public class LawsMonthlyReportWriteEOServiceImpl extends ServiceImpl<LawsMonthly
|
||||
}else{
|
||||
content = "Content";
|
||||
}
|
||||
String moth = lawsMonthlyReportWriteEOS.get(0).getMonth().replaceAll("-", "年") + "月";
|
||||
//单独设置每页右侧的时间
|
||||
WordUtil.exportWord(document, titleCN, null, ParagraphAlignment.CENTER, 0, 12, false, true, "Microsoft YaHei UI");
|
||||
WordUtil.exportWord(document, content, null, ParagraphAlignment.LEFT, 0, 12, false, true, "Microsoft YaHei UI");
|
||||
//生成页眉页脚
|
||||
WordUtil.exportHeardAndFoot(document,lawsMonthlyReportWriteEOS.get(0).getMonth());
|
||||
WordUtil.exportWord(document, titleCN, null, ParagraphAlignment.CENTER, 0, 18, false, false, "Blue Sky Noto Regular");
|
||||
WordUtil.exportWord(document, content, null, ParagraphAlignment.LEFT, 0, 12, false, true, "Blue Sky Noto Regular");
|
||||
//生成页脚
|
||||
WordUtil.exportHeardAndFootMain(document,moth);
|
||||
int oneCount = 1;
|
||||
|
||||
for (LawsMonthlyReportTitleTemplateEO lawsMonthlyReportTitleTemplateEO : reportTitleOneList) {
|
||||
@@ -564,7 +565,7 @@ public class LawsMonthlyReportWriteEOServiceImpl extends ServiceImpl<LawsMonthly
|
||||
oneTitle = lawsMonthlyReportTitleTemplateEO.getTitleEn();
|
||||
}
|
||||
if(StringUtils.isNotBlank(oneTitle)){
|
||||
WordUtil.exportWord(document, oneNumber+" "+oneTitle, null, ParagraphAlignment.LEFT, 0, 12, false, true, "Microsoft YaHei UI");
|
||||
WordUtil.exportWord(document, oneNumber+" "+oneTitle, null, ParagraphAlignment.LEFT, 0, 12, false, true, "Blue Sky Noto Regular");
|
||||
oneCount++;
|
||||
}
|
||||
|
||||
@@ -586,7 +587,7 @@ public class LawsMonthlyReportWriteEOServiceImpl extends ServiceImpl<LawsMonthly
|
||||
twoTitle = monthlyReportTitleTemplateEO.getTitleEn();
|
||||
}
|
||||
if(StringUtils.isNotBlank(twoTitle)){
|
||||
WordUtil.exportWord(document, twoNumber+" "+twoTitle, null, ParagraphAlignment.LEFT, 2, 12, false, true, "Microsoft YaHei UI");
|
||||
WordUtil.exportWord(document, twoNumber+" "+twoTitle, null, ParagraphAlignment.LEFT, 2, 12, false, true, "Blue Sky Noto Regular");
|
||||
twoCount++;
|
||||
}
|
||||
|
||||
@@ -599,7 +600,7 @@ public class LawsMonthlyReportWriteEOServiceImpl extends ServiceImpl<LawsMonthly
|
||||
reportTitle = lawsMonthlyReportWriteEO.getTitleEn();
|
||||
}
|
||||
if(org.apache.commons.lang3.StringUtils.isNotBlank(reportTitle)){
|
||||
WordUtil.exportWord(document, reportCount+". "+reportTitle, null, ParagraphAlignment.LEFT, 6, 10, false, false, "Microsoft YaHei UI");
|
||||
WordUtil.exportWord(document, reportCount+". "+reportTitle, null, ParagraphAlignment.LEFT, 6, 12, false, false, "Blue Sky Noto Regular");
|
||||
reportCount++;
|
||||
}
|
||||
}
|
||||
@@ -617,15 +618,11 @@ public class LawsMonthlyReportWriteEOServiceImpl extends ServiceImpl<LawsMonthly
|
||||
|
||||
//树形数据字典
|
||||
List<SysCategory> categoryList = sysCategoryService.list();
|
||||
String content = "";
|
||||
if(CutEnum.CN.getValue().equals(cut)){
|
||||
content = "主要内容";
|
||||
}else{
|
||||
content = "Content";
|
||||
}
|
||||
WordUtil.exportWord(document, titleCN, null, ParagraphAlignment.CENTER, 0, 12, false, true, "Microsoft YaHei UI");
|
||||
String moth = lawsMonthlyReportWriteEOS.get(0).getMonth().replaceAll("-", "年") + "月";
|
||||
//生成页眉页脚
|
||||
WordUtil.exportHeardAndFoot(document,lawsMonthlyReportWriteEOS.get(0).getMonth());
|
||||
WordUtil.exportHeardAndFoot(document,moth);
|
||||
//生成标题
|
||||
WordUtil.exportWord(document, titleCN, null, ParagraphAlignment.CENTER, 0, 18, false, true, "Blue Sky Noto Regular");
|
||||
int oneCount = 1;
|
||||
|
||||
for (LawsMonthlyReportTitleTemplateEO lawsMonthlyReportTitleTemplateEO : reportTitleOneList) {
|
||||
@@ -639,7 +636,7 @@ public class LawsMonthlyReportWriteEOServiceImpl extends ServiceImpl<LawsMonthly
|
||||
oneTitle = lawsMonthlyReportTitleTemplateEO.getTitleEn();
|
||||
}
|
||||
if(StringUtils.isNotBlank(oneTitle)){
|
||||
WordUtil.exportWord(document, oneNumber+" "+oneTitle, null, ParagraphAlignment.LEFT, 0, 12, false, true, "Microsoft YaHei UI");
|
||||
WordUtil.exportWord(document, oneNumber+" "+oneTitle, null, ParagraphAlignment.LEFT, 0, 14, false, true, "Blue Sky Noto Regular");
|
||||
oneCount++;
|
||||
}
|
||||
|
||||
@@ -661,7 +658,7 @@ public class LawsMonthlyReportWriteEOServiceImpl extends ServiceImpl<LawsMonthly
|
||||
twoTitle = monthlyReportTitleTemplateEO.getTitleEn();
|
||||
}
|
||||
if(StringUtils.isNotBlank(twoTitle)){
|
||||
WordUtil.exportWord(document, twoNumber+" "+twoTitle, null, ParagraphAlignment.LEFT, 2, 12, false, true, "Microsoft YaHei UI");
|
||||
WordUtil.exportWord(document, twoNumber+" "+twoTitle, null, ParagraphAlignment.LEFT, 2, 12, false, true, "Blue Sky Noto Regular");
|
||||
twoCount++;
|
||||
}
|
||||
//二级目录下放--->新征求意见清单模板, 新发布标准清单模板
|
||||
@@ -686,7 +683,7 @@ public class LawsMonthlyReportWriteEOServiceImpl extends ServiceImpl<LawsMonthly
|
||||
reportTitle = lawsMonthlyReportWriteEO.getTitleEn();
|
||||
}
|
||||
if(StringUtils.isNotBlank(reportTitle)){
|
||||
WordUtil.exportWord(document, reportCount+". "+reportTitle, null, ParagraphAlignment.LEFT, 6, 10, false, false, "Microsoft YaHei UI");
|
||||
WordUtil.exportWord(document, reportCount+". "+reportTitle, null, ParagraphAlignment.LEFT, 6, 11, false, false, "Blue Sky Noto Regular");
|
||||
}
|
||||
|
||||
|
||||
|
||||
+38
-4
@@ -224,15 +224,48 @@ public class WordUtil {
|
||||
if (sectPr == null) sectPr = document.getDocument().getBody().addNewSectPr();
|
||||
CTPageMar pageMar = sectPr.getPgMar();
|
||||
if (pageMar == null) pageMar = sectPr.addNewPgMar();
|
||||
pageMar.setLeft(BigInteger.valueOf(720)); //720 TWentieths of an Inch Point (Twips) = 720/20 = 36 pt = 36/72 = 0.5"
|
||||
pageMar.setRight(BigInteger.valueOf(720));
|
||||
pageMar.setTop(BigInteger.valueOf(1440)); //1440 Twips = 1440/20 = 72 pt = 72/72 = 1"
|
||||
pageMar.setBottom(BigInteger.valueOf(1440));
|
||||
pageMar.setLeft(BigInteger.valueOf(1000)); //左边距
|
||||
pageMar.setRight(BigInteger.valueOf(1000));//右边距
|
||||
pageMar.setTop(BigInteger.valueOf(1440)); //页眉高度
|
||||
pageMar.setBottom(BigInteger.valueOf(1440));//页脚高度
|
||||
|
||||
pageMar.setHeader(BigInteger.valueOf(500)); //页眉上边框到顶部的距离
|
||||
pageMar.setFooter(BigInteger.valueOf(800)); //页脚下边框到底部的距离
|
||||
}
|
||||
|
||||
/**
|
||||
* 主页面(只有页脚)
|
||||
* @param document
|
||||
* @param month
|
||||
*/
|
||||
@SneakyThrows
|
||||
public static void exportHeardAndFootMain(XWPFDocument document,String month){
|
||||
XWPFHeaderFooterPolicy headerFooterPolicy = document.getHeaderFooterPolicy();
|
||||
if (headerFooterPolicy == null) headerFooterPolicy = document.createHeaderFooterPolicy();
|
||||
// XWPFHeader header = headerFooterPolicy.createHeader(XWPFHeaderFooterPolicy.DEFAULT);
|
||||
// XWPFParagraph paragraph = header.createParagraph();//创建新的段落
|
||||
// XWPFRun run = paragraph.createRun();
|
||||
|
||||
XWPFFooter footer = headerFooterPolicy.createFooter(XWPFHeaderFooterPolicy.DEFAULT);
|
||||
XWPFParagraph paragraph = footer.createParagraph();
|
||||
paragraph.setAlignment(ParagraphAlignment.CENTER);
|
||||
XWPFRun run = paragraph.createRun();
|
||||
run.setText("NIO Internal");
|
||||
|
||||
|
||||
CTSectPr sectPr = document.getDocument().getBody().getSectPr();
|
||||
if (sectPr == null) sectPr = document.getDocument().getBody().addNewSectPr();
|
||||
CTPageMar pageMar = sectPr.getPgMar();
|
||||
if (pageMar == null) pageMar = sectPr.addNewPgMar();
|
||||
pageMar.setLeft(BigInteger.valueOf(1000)); //左边距
|
||||
pageMar.setRight(BigInteger.valueOf(1000));//右边距
|
||||
pageMar.setTop(BigInteger.valueOf(1440)); //页眉高度
|
||||
pageMar.setBottom(BigInteger.valueOf(1440));//页脚高度
|
||||
|
||||
pageMar.setHeader(BigInteger.valueOf(500)); //页眉上边框到顶部的距离
|
||||
pageMar.setFooter(BigInteger.valueOf(1200)); //页脚下边框到底部的距离
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出工具示例
|
||||
*
|
||||
@@ -628,6 +661,7 @@ public class WordUtil {
|
||||
}
|
||||
|
||||
private static void setCell(XWPFTableRow tableRow, String fieldName,String technologyTerritory) {
|
||||
|
||||
tableRow.setHeight(500);
|
||||
CTTblWidth ctTblWidth0 = tableRow.getCell(0).getCTTc().addNewTcPr().addNewTcW();
|
||||
ctTblWidth0.setType(STTblWidth.DXA);
|
||||
|
||||
Reference in New Issue
Block a user