fix null
This commit is contained in:
parent
e570c1879e
commit
db71ba0e5f
|
|
@ -10,10 +10,7 @@ import org.springframework.beans.BeanUtils;
|
|||
|
||||
import java.awt.Color;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
|
|
@ -115,7 +112,7 @@ public class ExcelUtilPlus {
|
|||
//遍历设置列宽
|
||||
List<Object> header = rowList.get(0);
|
||||
for (int i = 0; i < header.size(); i++) {
|
||||
sheet.setColumnWidth(i,Math.max(12, header.get(i).toString().length()*4)*256);
|
||||
sheet.setColumnWidth(i, Math.max(12, header.get(i).toString().length() * 4) * 256);
|
||||
}
|
||||
|
||||
for (int rowIndex = 0; rowIndex < rowList.size(); rowIndex++) {
|
||||
|
|
@ -199,7 +196,7 @@ public class ExcelUtilPlus {
|
|||
//遍历设置列宽
|
||||
List<Object> header = rowList.get(0);
|
||||
for (int i = 0; i < header.size(); i++) {
|
||||
sheet.setColumnWidth(i,Math.max(12, header.get(i).toString().length()*4)*256);
|
||||
sheet.setColumnWidth(i, Math.max(12, header.get(i).toString().length() * 4) * 256);
|
||||
}
|
||||
|
||||
for (int rowIndex = 0; rowIndex < rowList.size(); rowIndex++) {
|
||||
|
|
@ -304,7 +301,7 @@ public class ExcelUtilPlus {
|
|||
//遍历设置列宽
|
||||
List<Object> header = rowList.get(0);
|
||||
for (int i = 0; i < header.size(); i++) {
|
||||
sheet.setColumnWidth(i,Math.max(12, header.get(i).toString().length()*4)*256);
|
||||
sheet.setColumnWidth(i, Math.max(12, header.get(i).toString().length() * 4) * 256);
|
||||
}
|
||||
|
||||
for (int rowIndex = 0; rowIndex < rowList.size(); rowIndex++) {
|
||||
|
|
@ -380,7 +377,6 @@ public class ExcelUtilPlus {
|
|||
childTitleCellStyle.setBorderBottom(BorderStyle.THIN);
|
||||
|
||||
|
||||
|
||||
// 设置主体样式
|
||||
XSSFCellStyle cellStyle = workbook.createCellStyle();
|
||||
XSSFFont font = workbook.createFont();
|
||||
|
|
@ -436,7 +432,7 @@ public class ExcelUtilPlus {
|
|||
rowOneCell.setCellValue(columnGroupItem.getText().toString());
|
||||
rowOneCell.setCellStyle(titleCellStyle);
|
||||
//设置列宽
|
||||
sheet.setColumnWidth(startIndex,Math.max(12, columnGroupItem.getText().length()*4)*256);
|
||||
sheet.setColumnWidth(startIndex, Math.max(12, columnGroupItem.getText().length() * 4) * 256);
|
||||
startIndex++;
|
||||
patternList.add(columnGroupItem.getPattern());
|
||||
} else {
|
||||
|
|
@ -458,7 +454,7 @@ public class ExcelUtilPlus {
|
|||
subHeader.setCellValue(childrenItem.getText().toString());
|
||||
subHeader.setCellStyle(titleCellStyle);
|
||||
//设置列宽
|
||||
sheet.setColumnWidth(startIndex + j,Math.max(12, childrenItem.getText().length()*4)*256);
|
||||
sheet.setColumnWidth(startIndex + j, Math.max(12, childrenItem.getText().length() * 4) * 256);
|
||||
patternList.add(childrenItem.getPattern());
|
||||
}
|
||||
|
||||
|
|
@ -471,10 +467,10 @@ public class ExcelUtilPlus {
|
|||
HashMap<Integer, XSSFCellStyle> numberCellStyleMap = new HashMap<Integer, XSSFCellStyle>();
|
||||
HashMap<Integer, XSSFCellStyle> numberRedCellStyleMap = new HashMap<Integer, XSSFCellStyle>();
|
||||
XSSFDataFormat df = workbook.createDataFormat();
|
||||
patternList.stream().distinct().forEach(p -> {
|
||||
patternList.stream().distinct().filter(a -> a != null).forEach(p -> {
|
||||
String start = "0.";
|
||||
if (p==0) {
|
||||
start ="0";
|
||||
if (p == 0) {
|
||||
start = "0";
|
||||
}
|
||||
XSSFCellStyle numberRedCellStyle = workbook.createCellStyle();
|
||||
BeanUtils.copyProperties(redCellStyle, numberRedCellStyle);
|
||||
|
|
@ -570,7 +566,6 @@ public class ExcelUtilPlus {
|
|||
childTitleCellStyle.setBorderBottom(BorderStyle.THIN);
|
||||
|
||||
|
||||
|
||||
// 设置主体样式
|
||||
XSSFCellStyle cellStyle = workbook.createCellStyle();
|
||||
XSSFFont font = workbook.createFont();
|
||||
|
|
@ -623,7 +618,7 @@ public class ExcelUtilPlus {
|
|||
rowOneCell.setCellValue(columnGroupItem.getText().toString());
|
||||
rowOneCell.setCellStyle(titleCellStyle);
|
||||
//设置列宽
|
||||
sheet.setColumnWidth(startIndex,Math.max(12, columnGroupItem.getText().length()*4)*256);
|
||||
sheet.setColumnWidth(startIndex, Math.max(12, columnGroupItem.getText().length() * 4) * 256);
|
||||
startIndex++;
|
||||
} else {
|
||||
List<WeaTableColumnGroup> childrenList = columnGroupItem.getChildren();
|
||||
|
|
@ -644,7 +639,7 @@ public class ExcelUtilPlus {
|
|||
subHeader.setCellValue(childrenItem.getText().toString());
|
||||
subHeader.setCellStyle(titleCellStyle);
|
||||
//设置列宽
|
||||
sheet.setColumnWidth(startIndex + j,Math.max(12, childrenItem.getText().length()*4)*256);
|
||||
sheet.setColumnWidth(startIndex + j, Math.max(12, childrenItem.getText().length() * 4) * 256);
|
||||
}
|
||||
|
||||
startIndex += childrenList.size();
|
||||
|
|
|
|||
Loading…
Reference in New Issue