月报导出--行间距(注释掉)

This commit is contained in:
zhn
2022-09-28 17:24:15 +08:00
parent e3527900fd
commit e0b606e943
2 changed files with 55 additions and 23 deletions
@@ -648,7 +648,7 @@ public class LawsMonthlyReportWriteEOServiceImpl extends ServiceImpl<LawsMonthly
XWPFDocument documentContentCn = new XWPFDocument();
FileOutputStream outContentCn = new FileOutputStream(wordFileContentCn);
//封面
cover(lawsMonthlyReportWriteEOS, titleCN, documentContentCn);
coverCn(lawsMonthlyReportWriteEOS, titleCN, documentContentCn);
// //目录
// catalogue(lawsMonthlyReportWriteEOS, lawsMonthlyReportTitleTemplateEOS, reportTitleOneList, "目录", documentContentCn,CutEnum.CN.getValue());
wordContent(lawsMonthlyReportWriteEOS, lawsMonthlyReportTitleTemplateEOS, reportTitleOneList, titleCN,
@@ -662,7 +662,7 @@ public class LawsMonthlyReportWriteEOServiceImpl extends ServiceImpl<LawsMonthly
XWPFDocument documentContentEn = new XWPFDocument();
FileOutputStream outContentEn = new FileOutputStream(wordFileContentEn);
//封面
cover(lawsMonthlyReportWriteEOS, titleEN, documentContentEn);
coverEn(lawsMonthlyReportWriteEOS, titleEN, documentContentEn);
// //目录
// catalogue(lawsMonthlyReportWriteEOS, lawsMonthlyReportTitleTemplateEOS, reportTitleOneList, "catalogue", documentContentEn,CutEnum.EN.getValue());
wordContent(lawsMonthlyReportWriteEOS, lawsMonthlyReportTitleTemplateEOS, reportTitleOneList, titleEN,
@@ -738,10 +738,10 @@ public class LawsMonthlyReportWriteEOServiceImpl extends ServiceImpl<LawsMonthly
String moth = lawsMonthlyReportWriteEOS.get(0).getMonth().replaceAll("-", "") + "";
//标题
WordUtil.exportWord(document, titleCN, null, ParagraphAlignment.CENTER, 0, 14,
false, false, "Blue Sky Noto Regular",null,null);
false, false, "Blue Sky Noto Regular",null,null,null);
//主要内容
WordUtil.exportWord(document, content, null, ParagraphAlignment.LEFT, 0, 12,
false, true, "Blue Sky Noto Regular",null,null);
false, true, "Blue Sky Noto Regular",null,null,null);
//生成页脚
WordUtil.exportHeardAndFootMain(document,moth);
int oneCount = 1;
@@ -758,7 +758,7 @@ public class LawsMonthlyReportWriteEOServiceImpl extends ServiceImpl<LawsMonthly
}
if(StringUtils.isNotBlank(oneTitle)){
WordUtil.exportWord(document, oneNumber+" "+oneTitle, null, ParagraphAlignment.LEFT,
0, 12, false, true, "Blue Sky Noto Regular","0","一级标题");
0, 12, false, true, "Blue Sky Noto Regular","0","一级标题",null);
oneCount++;
}
@@ -781,7 +781,7 @@ public class LawsMonthlyReportWriteEOServiceImpl extends ServiceImpl<LawsMonthly
}
if(StringUtils.isNotBlank(twoTitle)){
WordUtil.exportWord(document, twoNumber+" "+twoTitle, null, ParagraphAlignment.LEFT,
2, 12, false, true, "Blue Sky Noto Regular","1","二级标题");
2, 12, false, true, "Blue Sky Noto Regular","1","二级标题",null);
twoCount++;
}
@@ -795,7 +795,7 @@ public class LawsMonthlyReportWriteEOServiceImpl extends ServiceImpl<LawsMonthly
}
if(org.apache.commons.lang3.StringUtils.isNotBlank(reportTitle)){
WordUtil.exportWord(document, reportCount+". "+reportTitle, null, ParagraphAlignment.LEFT,
4, 12, false, false, "Blue Sky Noto Regular","2","三级标题");
4, 12, false, false, "Blue Sky Noto Regular","2","三级标题",null);
reportCount++;
}
}
@@ -812,7 +812,7 @@ public class LawsMonthlyReportWriteEOServiceImpl extends ServiceImpl<LawsMonthly
String moth = lawsMonthlyReportWriteEOS.get(0).getMonth().replaceAll("-", "") + "";
//单独设置每页右侧的时间
WordUtil.exportWord(document, catalogue, null, ParagraphAlignment.LEFT, 0, 18,
false, false, "Blue Sky Noto Regular",null,null);
false, false, "Blue Sky Noto Regular",null,null,null);
int oneCount = 1;
@@ -828,7 +828,7 @@ public class LawsMonthlyReportWriteEOServiceImpl extends ServiceImpl<LawsMonthly
}
if(StringUtils.isNotBlank(oneTitle)){
WordUtil.exportWord(document, oneNumber+" "+oneTitle, null, ParagraphAlignment.LEFT,
0, 12, false, true, "Blue Sky Noto Regular",null,null);
0, 12, false, true, "Blue Sky Noto Regular",null,null,null);
oneCount++;
}
@@ -851,7 +851,7 @@ public class LawsMonthlyReportWriteEOServiceImpl extends ServiceImpl<LawsMonthly
}
if(StringUtils.isNotBlank(twoTitle)){
WordUtil.exportWord(document, twoNumber+" "+twoTitle, null, ParagraphAlignment.LEFT,
0, 12, false, true, "Blue Sky Noto Regular",null,null);
0, 12, false, true, "Blue Sky Noto Regular",null,null,null);
twoCount++;
}
@@ -865,7 +865,7 @@ public class LawsMonthlyReportWriteEOServiceImpl extends ServiceImpl<LawsMonthly
}
if(org.apache.commons.lang3.StringUtils.isNotBlank(reportTitle)){
WordUtil.exportWord(document, reportCount+". "+reportTitle, null, ParagraphAlignment.LEFT,
0, 12, false, false, "Blue Sky Noto Regular",null,null);
0, 12, false, false, "Blue Sky Noto Regular",null,null,null);
reportCount++;
}
}
@@ -874,16 +874,32 @@ public class LawsMonthlyReportWriteEOServiceImpl extends ServiceImpl<LawsMonthly
}
//封面
private void cover(List<LawsMonthlyReportWriteEO> lawsMonthlyReportWriteEOS,
private void coverCn(List<LawsMonthlyReportWriteEO> lawsMonthlyReportWriteEOS,
String titleCN,
XWPFDocument document) {
//封面标识
String flag = "cover";
String moth = lawsMonthlyReportWriteEOS.get(0).getMonth().replaceAll("-", "") + "";
titleCN = "\r\n\r\n" + titleCN + "\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n";
WordUtil.exportWord(document, titleCN, null, ParagraphAlignment.CENTER, 0, 18,
false, false, "Blue Sky Noto Regular",null,null);
WordUtil.exportWord(document, moth, null, ParagraphAlignment.CENTER, 0, 12,
false, true, "Blue Sky Noto Regular",null,null);
false, false, "Blue Sky Noto Regular",null,null,flag);
WordUtil.exportWord(document, moth+"\r\n", null, ParagraphAlignment.CENTER, 0, 12,
false, true, "Blue Sky Noto Regular",null,null,flag);
}
//封面
private void coverEn(List<LawsMonthlyReportWriteEO> lawsMonthlyReportWriteEOS,
String titleCN,
XWPFDocument document) {
//封面标识
String flag = "cover";
String moth = lawsMonthlyReportWriteEOS.get(0).getMonth().replaceAll("-", "") + "";
titleCN = "\r\n\r\n" + titleCN + "\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n";
WordUtil.exportWord(document, titleCN, null, ParagraphAlignment.CENTER, 0, 18,
false, false, "Blue Sky Noto Regular",null,null,flag);
WordUtil.exportWord(document, moth+"\r\n", null, ParagraphAlignment.CENTER, 0, 12,
false, true, "Blue Sky Noto Regular",null,null,flag);
}
private void wordContent(List<LawsMonthlyReportWriteEO> lawsMonthlyReportWriteEOS,
List<LawsMonthlyReportTitleTemplateEO> lawsMonthlyReportTitleTemplateEOS,
@@ -904,8 +920,8 @@ public class LawsMonthlyReportWriteEOServiceImpl extends ServiceImpl<LawsMonthly
//生成页眉页脚
WordUtil.exportHeardAndFoot(document,moth);
//生成标题
WordUtil.exportWord(document, "", null, ParagraphAlignment.CENTER, 0, 18,
false, true, "Blue Sky Noto Regular",null,null);
// WordUtil.exportWord(document, "", null, ParagraphAlignment.CENTER, 0, 18,
// false, true, "Blue Sky Noto Regular",null,null,null);
int oneCount = 1;
for (LawsMonthlyReportTitleTemplateEO lawsMonthlyReportTitleTemplateEO : reportTitleOneList) {
@@ -924,7 +940,7 @@ public class LawsMonthlyReportWriteEOServiceImpl extends ServiceImpl<LawsMonthly
}
if(StringUtils.isNotBlank(oneTitle)){
WordUtil.exportWord(document, oneNumber+" "+oneTitle, null, ParagraphAlignment.LEFT,
0, 14, false, true, "Blue Sky Noto Regular","0","一级标题");
0, 14, false, true, "Blue Sky Noto Regular","0","一级标题","oneTitle");
oneCount++;
}
@@ -951,7 +967,7 @@ public class LawsMonthlyReportWriteEOServiceImpl extends ServiceImpl<LawsMonthly
}
if(StringUtils.isNotBlank(twoTitle)){
WordUtil.exportWord(document, twoNumber+" "+twoTitle, null, ParagraphAlignment.LEFT,
0, 12, false, true, "Blue Sky Noto Regular","1","二级标题");
0, 12, false, true, "Blue Sky Noto Regular","1","二级标题",null);
twoCount++;
}
//二级目录下放--->新征求意见清单模板, 新发布标准清单模板
@@ -960,13 +976,13 @@ public class LawsMonthlyReportWriteEOServiceImpl extends ServiceImpl<LawsMonthly
for (LawsMonthlyReportWriteEO lawsMonthlyReportWriteEO : askList) {
WordUtil.exportWordExcelAsk(document,lawsMonthlyReportWriteEO,cut);
WordUtil.exportWord(document, null, null, null,
0, 0, false, true, null,null,null);
0, 0, false, true, null,null,null,null);
}
for (LawsMonthlyReportWriteEO lawsMonthlyReportWriteEO : issueList) {
WordUtil.exportWordExcelIssue(document,lawsMonthlyReportWriteEO,cut);
WordUtil.exportWord(document, null, null, null, 0, 0,
false, true, null,null,null);
false, true, null,null,null,null);
}
for (LawsMonthlyReportWriteEO lawsMonthlyReportWriteEO : lawsMonthlyReportWriteEOList) {
@@ -979,7 +995,7 @@ public class LawsMonthlyReportWriteEOServiceImpl extends ServiceImpl<LawsMonthly
}
if(StringUtils.isNotBlank(reportTitle)){
WordUtil.exportWord(document, reportCount+". "+reportTitle, null, ParagraphAlignment.LEFT,
0, 11, false, false, "Blue Sky Noto Regular","2","三级标题");
0, 11, false, false, "Blue Sky Noto Regular","2","三级标题",null);
}
@@ -82,6 +82,7 @@ public class WordUtil {
* @param fontFamily 字体,默认宋体
* @param directoryLevel 目录级别
* @param styleName 标题样式
* @param flag 封面标识(不做行间距处理)
*/
public static void exportWord(XWPFDocument document,
String text,
@@ -93,7 +94,8 @@ public class WordUtil {
Boolean isBold,
String fontFamily,
String directoryLevel,
String styleName) {
String styleName,
String flag) {
//设置标题级别
if(StringUtils.isNotEmpty(directoryLevel)){
@@ -103,6 +105,20 @@ public class WordUtil {
XWPFParagraph titleParagraph = document.createParagraph();
titleParagraph.setStyle(styleName);
//设置行间距
// if(!"cover".equals(flag) && !"oneTitle".equals(flag)){
// CTP ctp = titleParagraph.getCTP();
// CTPPr ppr = ctp.isSetPPr() ? ctp.getPPr() : ctp.addNewPPr();
// CTSpacing spacing = ppr.isSetSpacing()? ppr.getSpacing() : ppr.addNewSpacing();
// spacing.setAfter(BigInteger.valueOf(0));
// spacing.setBefore(BigInteger.valueOf(0));
// //设置行距类型为 EXACT
// spacing.setLineRule(STLineSpacingRule.EXACT);
// //1磅数是20
// spacing.setLine(BigInteger.valueOf(40*20));
// }
//设置段落左对齐
if (align == null) {
titleParagraph.setAlignment(ParagraphAlignment.LEFT);