月报整合导出--word中导出表格错乱问题(法规联系人四个换行)

This commit is contained in:
zhn
2022-08-26 18:03:29 +08:00
parent 5846d39886
commit c70f183041
3 changed files with 57 additions and 15 deletions
@@ -647,8 +647,10 @@ public class LawsMonthlyReportWriteEOServiceImpl extends ServiceImpl<LawsMonthly
}
String moth = lawsMonthlyReportWriteEOS.get(0).getMonth().replaceAll("-", "") + "";
//单独设置每页右侧的时间
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.exportWord(document, titleCN, null, ParagraphAlignment.CENTER, 0, 18,
false, false, "Blue Sky Noto Regular",null);
WordUtil.exportWord(document, content, null, ParagraphAlignment.LEFT, 0, 12,
false, true, "Blue Sky Noto Regular",null);
//生成页脚
WordUtil.exportHeardAndFootMain(document,moth);
int oneCount = 1;
@@ -664,7 +666,8 @@ 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, "Blue Sky Noto Regular");
WordUtil.exportWord(document, oneNumber+" "+oneTitle, null, ParagraphAlignment.LEFT,
0, 12, false, true, "Blue Sky Noto Regular",null);
oneCount++;
}
@@ -686,7 +689,8 @@ 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, "Blue Sky Noto Regular");
WordUtil.exportWord(document, twoNumber+" "+twoTitle, null, ParagraphAlignment.LEFT,
2, 12, false, true, "Blue Sky Noto Regular",null);
twoCount++;
}
@@ -699,7 +703,8 @@ 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, 12, false, false, "Blue Sky Noto Regular");
WordUtil.exportWord(document, reportCount+". "+reportTitle, null, ParagraphAlignment.LEFT,
6, 12, false, false, "Blue Sky Noto Regular",null);
reportCount++;
}
}
@@ -722,7 +727,8 @@ public class LawsMonthlyReportWriteEOServiceImpl extends ServiceImpl<LawsMonthly
//生成页眉页脚
WordUtil.exportHeardAndFoot(document,moth);
//生成标题
WordUtil.exportWord(document, titleCN, null, ParagraphAlignment.CENTER, 0, 18, false, true, "Blue Sky Noto Regular");
WordUtil.exportWord(document, titleCN, null, ParagraphAlignment.CENTER, 0, 18,
false, true, "Blue Sky Noto Regular",null);
int oneCount = 1;
for (LawsMonthlyReportTitleTemplateEO lawsMonthlyReportTitleTemplateEO : reportTitleOneList) {
@@ -736,7 +742,8 @@ public class LawsMonthlyReportWriteEOServiceImpl extends ServiceImpl<LawsMonthly
oneTitle = lawsMonthlyReportTitleTemplateEO.getTitleEn();
}
if(StringUtils.isNotBlank(oneTitle)){
WordUtil.exportWord(document, oneNumber+" "+oneTitle, null, ParagraphAlignment.LEFT, 0, 14, false, true, "Blue Sky Noto Regular");
WordUtil.exportWord(document, oneNumber+" "+oneTitle, null, ParagraphAlignment.LEFT,
0, 14, false, true, "Blue Sky Noto Regular","1");
oneCount++;
}
@@ -758,7 +765,8 @@ 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, "Blue Sky Noto Regular");
WordUtil.exportWord(document, twoNumber+" "+twoTitle, null, ParagraphAlignment.LEFT,
2, 12, false, true, "Blue Sky Noto Regular","2");
twoCount++;
}
//二级目录下放--->新征求意见清单模板, 新发布标准清单模板
@@ -766,12 +774,14 @@ public class LawsMonthlyReportWriteEOServiceImpl extends ServiceImpl<LawsMonthly
List<LawsMonthlyReportWriteEO> issueList = lawsMonthlyReportWriteEOList.stream().filter(e -> ContentTemplateEnum.NEW_RELEASE_STANDARD_MANIFEST_TEMPLATE.getValue().equals(e.getContentTemplate())).collect(Collectors.toList());
for (LawsMonthlyReportWriteEO lawsMonthlyReportWriteEO : askList) {
WordUtil.exportWordExcelAsk(document,lawsMonthlyReportWriteEO,cut);
WordUtil.exportWord(document, null, null, null, 0, 0, false, true, null);
WordUtil.exportWord(document, null, null, null,
0, 0, false, true, null,null);
}
for (LawsMonthlyReportWriteEO lawsMonthlyReportWriteEO : issueList) {
WordUtil.exportWordExcelIssue(document,lawsMonthlyReportWriteEO,cut);
WordUtil.exportWord(document, null, null, null, 0, 0, false, true, null);
WordUtil.exportWord(document, null, null, null, 0, 0,
false, true, null,null);
}
for (LawsMonthlyReportWriteEO lawsMonthlyReportWriteEO : lawsMonthlyReportWriteEOList) {
@@ -783,7 +793,8 @@ public class LawsMonthlyReportWriteEOServiceImpl extends ServiceImpl<LawsMonthly
reportTitle = lawsMonthlyReportWriteEO.getTitleEn();
}
if(StringUtils.isNotBlank(reportTitle)){
WordUtil.exportWord(document, reportCount+". "+reportTitle, null, ParagraphAlignment.LEFT, 6, 11, false, false, "Blue Sky Noto Regular");
WordUtil.exportWord(document, reportCount+". "+reportTitle, null, ParagraphAlignment.LEFT,
6, 11, false, false, "Blue Sky Noto Regular","3");
}
@@ -23,7 +23,6 @@ import org.apache.poi.xwpf.usermodel.XWPFPicture;
import org.apache.poi.xwpf.usermodel.XWPFPictureData;
import org.apache.poi.xwpf.usermodel.XWPFRun;
import org.apache.poi.xwpf.usermodel.XWPFTable;
import org.apache.poi.xwpf.usermodel.XWPFTableRow;
import org.apache.xmlbeans.impl.xb.xmlschema.SpaceAttribute;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTFldChar;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTJc;
@@ -56,6 +55,7 @@ public class WordUtil {
* @param isNewline 是否换行,换行后文本失效
* @param isBold 是否加粗,默认不加粗
* @param fontFamily 字体,默认宋体
* @param directoryLevel 目录级别
*/
public static void exportWord(XWPFDocument document,
String text,
@@ -65,12 +65,15 @@ public class WordUtil {
Integer fontSize,
Boolean isNewline,
Boolean isBold,
String fontFamily) {
document.createParagraph();
String fontFamily,String directoryLevel) {
//添加标题
XWPFParagraph titleParagraph = document.createParagraph();
if(StringUtils.isNotEmpty(directoryLevel)){
titleParagraph.setStyle(directoryLevel);
}
//设置段落左对齐
if (align == null) {
titleParagraph.setAlignment(ParagraphAlignment.LEFT);
@@ -366,6 +369,24 @@ public class WordUtil {
String workProgressEn = lawsMonthlyReportWriteEO.getWorkProgressEn();//NIO工作进展英文
String lawsContactTemp = lawsMonthlyReportWriteEO.getLawsContact();//法规联系人
String lawsContact = getLawsContact(loginUserList, lawsContactTemp);
List<String> lawsContactList = Arrays.asList(lawsContact.split(","));
if (lawsContactList.size() > 4) {
StringBuilder str = new StringBuilder();
int count = 0;
for (String s : lawsContactList) {
str.append(s + ",");
count++;
if (count % 4 == 0) {
str.append("\n");
}
}
if(str.toString().endsWith("\n")){
lawsContact = str.substring(0,str.length()-2);
}else{
lawsContact = str.substring(0,str.length()-1);
}
}
String link = lawsMonthlyReportWriteEO.getLink();//链接
String technologyTerritoryName = "";
if(org.apache.commons.lang3.StringUtils.isNotBlank(technologyTerritory)){
+10
View File
@@ -91,6 +91,11 @@
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
<id>com.e-iceblue</id>
<name>e-iceblue</name>
<url>https://repo.e-iceblue.cn/repository/maven-public/</url>
</repository>
</repositories>
<dependencies>
@@ -110,6 +115,11 @@
<artifactId>fastjson</artifactId>
<version>${fastjson.version}</version>
</dependency>
<dependency>
<groupId>e-iceblue</groupId>
<artifactId>spire.office.free</artifactId>
<version>5.3.1</version>
</dependency>
</dependencies>
<dependencyManagement>