|
@@ -11,6 +11,7 @@ import com.ruoyi.common.core.utils.file.FileTypeUtils;
|
|
|
import com.ruoyi.common.core.utils.file.ImageUtils;
|
|
|
import com.ruoyi.common.core.utils.poi.ExcelHandlerAdapter;
|
|
|
import com.ruoyi.common.core.utils.reflect.ReflectUtils;
|
|
|
+
|
|
|
import java.io.IOException;
|
|
|
import java.io.InputStream;
|
|
|
import java.lang.reflect.Field;
|
|
@@ -94,7 +95,7 @@ public class ExcelUtilImage<T> {
|
|
|
list = new ArrayList();
|
|
|
}
|
|
|
|
|
|
- this.list = (List)list;
|
|
|
+ this.list = (List) list;
|
|
|
this.sheetName = sheetName;
|
|
|
this.type = type;
|
|
|
this.title = title;
|
|
@@ -118,7 +119,7 @@ public class ExcelUtilImage<T> {
|
|
|
Row titleRow = var10000.createRow(var10001);
|
|
|
titleRow.setHeightInPoints(30.0F);
|
|
|
Cell titleCell = titleRow.createCell(0);
|
|
|
- titleCell.setCellStyle((CellStyle)this.styles.get("title"));
|
|
|
+ titleCell.setCellStyle((CellStyle) this.styles.get("title"));
|
|
|
titleCell.setCellValue(this.title);
|
|
|
this.sheet.addMergedRegion(new CellRangeAddress(titleRow.getRowNum(), titleRow.getRowNum(), titleRow.getRowNum(), this.fields.size() - 1));
|
|
|
}
|
|
@@ -146,13 +147,13 @@ public class ExcelUtilImage<T> {
|
|
|
Map<String, Integer> cellMap = new HashMap();
|
|
|
Row heard = sheet.getRow(titleNum);
|
|
|
|
|
|
- for(int i = 0; i < heard.getPhysicalNumberOfCells(); ++i) {
|
|
|
+ for (int i = 0; i < heard.getPhysicalNumberOfCells(); ++i) {
|
|
|
Cell cell = heard.getCell(i);
|
|
|
if (StringUtils.isNotNull(cell)) {
|
|
|
String value = this.getCellValue(heard, i).toString();
|
|
|
cellMap.put(value, i);
|
|
|
} else {
|
|
|
- cellMap.put(String.valueOf((Object)null), i);
|
|
|
+ cellMap.put(String.valueOf((Object) null), i);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -160,27 +161,27 @@ public class ExcelUtilImage<T> {
|
|
|
Map<Integer, Object[]> fieldsMap = new HashMap();
|
|
|
Iterator var24 = fields.iterator();
|
|
|
|
|
|
- while(var24.hasNext()) {
|
|
|
- Object[] objects = (Object[])var24.next();
|
|
|
- Excel attr = (Excel)objects[1];
|
|
|
- Integer column = (Integer)cellMap.get(attr.name());
|
|
|
+ while (var24.hasNext()) {
|
|
|
+ Object[] objects = (Object[]) var24.next();
|
|
|
+ Excel attr = (Excel) objects[1];
|
|
|
+ Integer column = (Integer) cellMap.get(attr.name());
|
|
|
if (column != null) {
|
|
|
fieldsMap.put(column, objects);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- for(int i = titleNum + 1; i <= rows; ++i) {
|
|
|
+ for (int i = titleNum + 1; i <= rows; ++i) {
|
|
|
Row row = sheet.getRow(i);
|
|
|
if (!this.isRowEmpty(row)) {
|
|
|
T entity = null;
|
|
|
Iterator var28 = fieldsMap.entrySet().iterator();
|
|
|
|
|
|
- while(var28.hasNext()) {
|
|
|
- Entry<Integer, Object[]> entry = (Entry)var28.next();
|
|
|
- Object val = this.getCellValue(row, (Integer)entry.getKey());
|
|
|
+ while (var28.hasNext()) {
|
|
|
+ Entry<Integer, Object[]> entry = (Entry) var28.next();
|
|
|
+ Object val = this.getCellValue(row, (Integer) entry.getKey());
|
|
|
entity = entity == null ? this.clazz.newInstance() : entity;
|
|
|
- Field field = (Field)((Object[])entry.getValue())[0];
|
|
|
- Excel attr = (Excel)((Object[])entry.getValue())[1];
|
|
|
+ Field field = (Field) ((Object[]) entry.getValue())[0];
|
|
|
+ Excel attr = (Excel) ((Object[]) entry.getValue())[1];
|
|
|
Class<?> fieldType = field.getType();
|
|
|
String propertyName;
|
|
|
if (String.class == fieldType) {
|
|
@@ -188,7 +189,7 @@ public class ExcelUtilImage<T> {
|
|
|
if (StringUtils.endsWith(propertyName, ".0")) {
|
|
|
val = StringUtils.substringBefore(propertyName, ".0");
|
|
|
} else {
|
|
|
- String dateFormat = ((Excel)field.getAnnotation(Excel.class)).dateFormat();
|
|
|
+ String dateFormat = ((Excel) field.getAnnotation(Excel.class)).dateFormat();
|
|
|
if (StringUtils.isNotEmpty(dateFormat)) {
|
|
|
val = this.parseDateToStr(dateFormat, val);
|
|
|
} else {
|
|
@@ -207,7 +208,7 @@ public class ExcelUtilImage<T> {
|
|
|
if (val instanceof String) {
|
|
|
val = DateUtils.parseDate(val);
|
|
|
} else if (val instanceof Double) {
|
|
|
- val = DateUtil.getJavaDate((Double)val);
|
|
|
+ val = DateUtil.getJavaDate((Double) val);
|
|
|
}
|
|
|
} else if (Boolean.TYPE == fieldType || Boolean.class == fieldType) {
|
|
|
val = Convert.toBool(val, false);
|
|
@@ -260,13 +261,14 @@ public class ExcelUtilImage<T> {
|
|
|
public void importTemplateExcel(HttpServletResponse response, String sheetName, String title) {
|
|
|
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
|
|
response.setCharacterEncoding("utf-8");
|
|
|
- this.init((List)null, sheetName, title, Type.IMPORT);
|
|
|
+ this.init((List) null, sheetName, title, Type.IMPORT);
|
|
|
this.exportExcel(response);
|
|
|
}
|
|
|
|
|
|
public void exportExcel(HttpServletResponse response) {
|
|
|
try {
|
|
|
this.writeSheet();
|
|
|
+ this.addSignatureAndDate(this.sheet); // 在写入数据后添加签名和日期
|
|
|
this.wb.write(response.getOutputStream());
|
|
|
} catch (Exception var6) {
|
|
|
log.error("导出Excel异常{}", var6.getMessage());
|
|
@@ -276,18 +278,41 @@ public class ExcelUtilImage<T> {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ public void addSignatureAndDate(Sheet sheet) {
|
|
|
+ try {
|
|
|
+ // 获取最后一行的行号
|
|
|
+ int lastRowNum = sheet.getLastRowNum();
|
|
|
+ // 检查是否需要创建新行,如果最后一行不为空,则在其下创建新行
|
|
|
+ int newRowNum = (lastRowNum == 0 || !isRowEmpty(sheet.getRow(lastRowNum))) ? lastRowNum + 2 : lastRowNum;
|
|
|
+ Row signatureAndDateRow = sheet.createRow(newRowNum);
|
|
|
+ Cell signatureCell = signatureAndDateRow.createCell(0);
|
|
|
+ signatureCell.setCellValue("负责人签名:");
|
|
|
+ Cell dateCell = signatureAndDateRow.createCell(4);
|
|
|
+ dateCell.setCellValue("日期:");
|
|
|
+ CellStyle style = this.wb.createCellStyle();
|
|
|
+ Font font = this.wb.createFont();
|
|
|
+ font.setBold(true);
|
|
|
+ style.setFont(font);
|
|
|
+ signatureCell.setCellStyle(style);
|
|
|
+ dateCell.setCellStyle(style);
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("Error adding signature and date to the Excel sheet.", e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
public void writeSheet() {
|
|
|
- int sheetNo = Math.max(1, (int)Math.ceil((double)this.list.size() * 1.0D / 65536.0D));
|
|
|
+ int sheetNo = Math.max(1, (int) Math.ceil((double) this.list.size() * 1.0D / 65536.0D));
|
|
|
|
|
|
- for(int index = 0; index < sheetNo; ++index) {
|
|
|
+ for (int index = 0; index < sheetNo; ++index) {
|
|
|
this.createSheet(sheetNo, index);
|
|
|
Row row = this.sheet.createRow(this.rownum);
|
|
|
int column = 0;
|
|
|
Iterator var5 = this.fields.iterator();
|
|
|
|
|
|
- while(var5.hasNext()) {
|
|
|
- Object[] os = (Object[])var5.next();
|
|
|
- Excel excel = (Excel)os[1];
|
|
|
+ while (var5.hasNext()) {
|
|
|
+ Object[] os = (Object[]) var5.next();
|
|
|
+ Excel excel = (Excel) os[1];
|
|
|
this.createCell(excel, row, column++);
|
|
|
}
|
|
|
|
|
@@ -300,28 +325,7 @@ public class ExcelUtilImage<T> {
|
|
|
}
|
|
|
|
|
|
|
|
|
-/* public void fillExcelData(int index, Row row) {
|
|
|
- int startNo = index * 65536;
|
|
|
- int endNo = Math.min(startNo + 65536, this.list.size());
|
|
|
-
|
|
|
- for(int i = startNo; i < endNo; ++i) {
|
|
|
- row = this.sheet.createRow(i + 1 + this.rownum - startNo);
|
|
|
- T vo = this.list.get(i);
|
|
|
- int column = 0;
|
|
|
- Iterator var8 = this.fields.iterator();
|
|
|
-
|
|
|
- while(var8.hasNext()) {
|
|
|
- Object[] os = (Object[])var8.next();
|
|
|
- Field field = (Field)os[0];
|
|
|
- Excel excel = (Excel)os[1];
|
|
|
- this.addCell(excel, row, vo, field, column++);
|
|
|
- }
|
|
|
- }
|
|
|
- }*/
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-/* public void fillExcelData(int index, Row row) {
|
|
|
+ public void fillExcelData(int index, Row row) {
|
|
|
int startNo = index * 65536;
|
|
|
int endNo = Math.min(startNo + 65536, this.list.size());
|
|
|
|
|
@@ -335,97 +339,11 @@ public class ExcelUtilImage<T> {
|
|
|
Object[] os = (Object[]) var8.next();
|
|
|
Field field = (Field) os[0];
|
|
|
Excel excel = (Excel) os[1];
|
|
|
- if (excel.isExport()) {
|
|
|
- if (field.getType().isAssignableFrom(List.class)) {
|
|
|
- // 处理List类型的字段
|
|
|
- List<?> listValue = null;
|
|
|
- try {
|
|
|
- listValue = (List<?>) this.getTargetValue(vo, field, excel);
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- for (Object item : listValue) {
|
|
|
- Cell cell = row.createCell(column);
|
|
|
- cell.setCellValue(item.toString());
|
|
|
- column++;
|
|
|
- }
|
|
|
- } else {
|
|
|
- // 处理非List类型的字段
|
|
|
- this.addCell(excel, row, vo, field, column++);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }*/
|
|
|
-
|
|
|
- public void fillExcelData(int index, Row row) {
|
|
|
- int startNo = index * 65536;
|
|
|
- int endNo = Math.min(startNo + 65536, this.list.size());
|
|
|
-
|
|
|
- for (int i = startNo; i < endNo; ++i) {
|
|
|
- row = this.sheet.createRow(i + 1 + this.rownum - startNo);
|
|
|
- T vo = this.list.get(i);
|
|
|
- int column = 0;
|
|
|
- Iterator<Object[]> var8 = this.fields.iterator();
|
|
|
-
|
|
|
- while (var8.hasNext()) {
|
|
|
- Object[] os = (Object[]) var8.next();
|
|
|
- Field field = (Field) os[0];
|
|
|
- Excel excel = (Excel) os[1];
|
|
|
- if (excel.isExport()) {
|
|
|
- if (field.getType().isAssignableFrom(List.class)) {
|
|
|
- // 处理List类型的字段
|
|
|
- addListCell(excel, row, vo, field, column);
|
|
|
- try {
|
|
|
- column += ((List<?>) this.getTargetValue(vo, field, excel)).size();
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- } else {
|
|
|
- // 处理非List类型的字段
|
|
|
- addCell(excel, row, vo, field, column++);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- public void addListCell(Excel attr, Row row, T vo, Field field, int column) {
|
|
|
- try {
|
|
|
- Object value = this.getTargetValue(vo, field, attr);
|
|
|
- if (value instanceof List) {
|
|
|
- List<?> listValue = (List<?>) value;
|
|
|
- for (int j = 0; j < listValue.size(); j++) {
|
|
|
- Cell cell = row.createCell(column + j);
|
|
|
- cell.setCellValue(listValue.get(j).toString());
|
|
|
- }
|
|
|
+ this.addCell(excel, row, vo, field, column++);
|
|
|
}
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("导出Excel失败{}", e);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-/* public Cell addListCell(Excel attr, Row row, T vo, Field field, int column) {
|
|
|
- Cell cell = row.createCell(column);
|
|
|
- StringBuilder sb = new StringBuilder();
|
|
|
- try {
|
|
|
- Object value = this.getTargetValue(vo, field, attr);
|
|
|
- if (value instanceof List) {
|
|
|
- List<?> listValue = (List<?>) value;
|
|
|
- for (int j = 0; j < listValue.size(); j++) {
|
|
|
- sb.append(listValue.get(j).toString());
|
|
|
- if (j < listValue.size() - 1) {
|
|
|
- sb.append("");
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- cell.setCellValue(sb.toString());
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("导出Excel失败{}", e);
|
|
|
- }
|
|
|
- return cell;
|
|
|
- }*/
|
|
|
-
|
|
|
private Map<String, CellStyle> createStyles(Workbook wb) {
|
|
|
Map<String, CellStyle> styles = new HashMap();
|
|
|
CellStyle style = wb.createCellStyle();
|
|
@@ -433,7 +351,7 @@ public class ExcelUtilImage<T> {
|
|
|
style.setVerticalAlignment(VerticalAlignment.CENTER);
|
|
|
Font titleFont = wb.createFont();
|
|
|
titleFont.setFontName("Arial");
|
|
|
- titleFont.setFontHeightInPoints((short)16);
|
|
|
+ titleFont.setFontHeightInPoints((short) 16);
|
|
|
titleFont.setBold(true);
|
|
|
style.setFont(titleFont);
|
|
|
styles.put("title", style);
|
|
@@ -450,18 +368,18 @@ public class ExcelUtilImage<T> {
|
|
|
style.setBottomBorderColor(IndexedColors.GREY_50_PERCENT.getIndex());
|
|
|
Font dataFont = wb.createFont();
|
|
|
dataFont.setFontName("Arial");
|
|
|
- dataFont.setFontHeightInPoints((short)10);
|
|
|
+ dataFont.setFontHeightInPoints((short) 10);
|
|
|
style.setFont(dataFont);
|
|
|
styles.put("data", style);
|
|
|
style = wb.createCellStyle();
|
|
|
- style.cloneStyleFrom((CellStyle)styles.get("data"));
|
|
|
+ style.cloneStyleFrom((CellStyle) styles.get("data"));
|
|
|
style.setAlignment(HorizontalAlignment.CENTER);
|
|
|
style.setVerticalAlignment(VerticalAlignment.CENTER);
|
|
|
style.setFillForegroundColor(IndexedColors.GREY_50_PERCENT.getIndex());
|
|
|
style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
|
|
|
Font headerFont = wb.createFont();
|
|
|
headerFont.setFontName("Arial");
|
|
|
- headerFont.setFontHeightInPoints((short)10);
|
|
|
+ headerFont.setFontHeightInPoints((short) 10);
|
|
|
headerFont.setBold(true);
|
|
|
headerFont.setColor(IndexedColors.WHITE.getIndex());
|
|
|
style.setFont(headerFont);
|
|
@@ -471,19 +389,19 @@ public class ExcelUtilImage<T> {
|
|
|
style.setVerticalAlignment(VerticalAlignment.CENTER);
|
|
|
Font totalFont = wb.createFont();
|
|
|
totalFont.setFontName("Arial");
|
|
|
- totalFont.setFontHeightInPoints((short)10);
|
|
|
+ totalFont.setFontHeightInPoints((short) 10);
|
|
|
style.setFont(totalFont);
|
|
|
styles.put("total", style);
|
|
|
style = wb.createCellStyle();
|
|
|
- style.cloneStyleFrom((CellStyle)styles.get("data"));
|
|
|
+ style.cloneStyleFrom((CellStyle) styles.get("data"));
|
|
|
style.setAlignment(HorizontalAlignment.LEFT);
|
|
|
styles.put("data1", style);
|
|
|
style = wb.createCellStyle();
|
|
|
- style.cloneStyleFrom((CellStyle)styles.get("data"));
|
|
|
+ style.cloneStyleFrom((CellStyle) styles.get("data"));
|
|
|
style.setAlignment(HorizontalAlignment.CENTER);
|
|
|
styles.put("data2", style);
|
|
|
style = wb.createCellStyle();
|
|
|
- style.cloneStyleFrom((CellStyle)styles.get("data"));
|
|
|
+ style.cloneStyleFrom((CellStyle) styles.get("data"));
|
|
|
style.setAlignment(HorizontalAlignment.RIGHT);
|
|
|
styles.put("data3", style);
|
|
|
return styles;
|
|
@@ -493,7 +411,7 @@ public class ExcelUtilImage<T> {
|
|
|
Cell cell = row.createCell(column);
|
|
|
cell.setCellValue(attr.name());
|
|
|
this.setDataValidation(attr, row, column);
|
|
|
- cell.setCellStyle((CellStyle)this.styles.get("header"));
|
|
|
+ cell.setCellStyle((CellStyle) this.styles.get("header"));
|
|
|
return cell;
|
|
|
}
|
|
|
|
|
@@ -507,10 +425,10 @@ public class ExcelUtilImage<T> {
|
|
|
cell.setCellValue(StringUtils.isNull(cellValue) ? attr.defaultValue() : cellValue + attr.suffix());
|
|
|
} else if (ColumnType.NUMERIC == attr.cellType()) {
|
|
|
if (StringUtils.isNotNull(value)) {
|
|
|
- cell.setCellValue(StringUtils.contains(Convert.toStr(value), ".") ? Convert.toDouble(value) : (double)Convert.toInt(value));
|
|
|
+ cell.setCellValue(StringUtils.contains(Convert.toStr(value), ".") ? Convert.toDouble(value) : (double) Convert.toInt(value));
|
|
|
}
|
|
|
} else if (ColumnType.IMAGE == attr.cellType()) {
|
|
|
- ClientAnchor anchor = new XSSFClientAnchor(0, 0, 0, 0, (short)cell.getColumnIndex(), cell.getRow().getRowNum(), (short)(cell.getColumnIndex() + 1), cell.getRow().getRowNum() + 1);
|
|
|
+ ClientAnchor anchor = new XSSFClientAnchor(0, 0, 0, 0, (short) cell.getColumnIndex(), cell.getRow().getRowNum(), (short) (cell.getColumnIndex() + 1), cell.getRow().getRowNum() + 1);
|
|
|
String imagePath = Convert.toStr(value);
|
|
|
if (StringUtils.isNotEmpty(imagePath)) {
|
|
|
byte[] data = ImageUtils.getImage(imagePath);
|
|
@@ -541,7 +459,7 @@ public class ExcelUtilImage<T> {
|
|
|
if (attr.name().indexOf("注:") >= 0) {
|
|
|
this.sheet.setColumnWidth(column, 6000);
|
|
|
} else {
|
|
|
- this.sheet.setColumnWidth(column, (int)((attr.width() + 0.72D) * 256.0D));
|
|
|
+ this.sheet.setColumnWidth(column, (int) ((attr.width() + 0.72D) * 256.0D));
|
|
|
}
|
|
|
|
|
|
if (StringUtils.isNotEmpty(attr.prompt()) || attr.combo().length > 0) {
|
|
@@ -610,14 +528,14 @@ public class ExcelUtilImage<T> {
|
|
|
String[] var5 = convertSource;
|
|
|
int var6 = convertSource.length;
|
|
|
|
|
|
- for(int var7 = 0; var7 < var6; ++var7) {
|
|
|
+ for (int var7 = 0; var7 < var6; ++var7) {
|
|
|
String item = var5[var7];
|
|
|
String[] itemArray = item.split("=");
|
|
|
if (StringUtils.containsAny(separator, propertyValue)) {
|
|
|
String[] var10 = propertyValue.split(separator);
|
|
|
int var11 = var10.length;
|
|
|
|
|
|
- for(int var12 = 0; var12 < var11; ++var12) {
|
|
|
+ for (int var12 = 0; var12 < var11; ++var12) {
|
|
|
String value = var10[var12];
|
|
|
if (itemArray[0].equals(value)) {
|
|
|
propertyString.append(itemArray[1] + separator);
|
|
@@ -638,14 +556,14 @@ public class ExcelUtilImage<T> {
|
|
|
String[] var5 = convertSource;
|
|
|
int var6 = convertSource.length;
|
|
|
|
|
|
- for(int var7 = 0; var7 < var6; ++var7) {
|
|
|
+ for (int var7 = 0; var7 < var6; ++var7) {
|
|
|
String item = var5[var7];
|
|
|
String[] itemArray = item.split("=");
|
|
|
if (StringUtils.containsAny(separator, propertyValue)) {
|
|
|
String[] var10 = propertyValue.split(separator);
|
|
|
int var11 = var10.length;
|
|
|
|
|
|
- for(int var12 = 0; var12 < var11; ++var12) {
|
|
|
+ for (int var12 = 0; var12 < var11; ++var12) {
|
|
|
String value = var10[var12];
|
|
|
if (itemArray[1].equals(value)) {
|
|
|
propertyString.append(itemArray[0] + separator);
|
|
@@ -684,7 +602,7 @@ public class ExcelUtilImage<T> {
|
|
|
} catch (NumberFormatException var6) {
|
|
|
}
|
|
|
|
|
|
- this.statistics.put(index, (Double)this.statistics.get(index) + temp);
|
|
|
+ this.statistics.put(index, (Double) this.statistics.get(index) + temp);
|
|
|
}
|
|
|
|
|
|
}
|
|
@@ -694,14 +612,13 @@ public class ExcelUtilImage<T> {
|
|
|
Row row = this.sheet.createRow(this.sheet.getLastRowNum() + 1);
|
|
|
Set<Integer> keys = this.statistics.keySet();
|
|
|
Cell cell = row.createCell(0);
|
|
|
- cell.setCellStyle((CellStyle)this.styles.get("total"));
|
|
|
+ cell.setCellStyle((CellStyle) this.styles.get("total"));
|
|
|
cell.setCellValue("合计");
|
|
|
Iterator var4 = keys.iterator();
|
|
|
-
|
|
|
- while(var4.hasNext()) {
|
|
|
- Integer key = (Integer)var4.next();
|
|
|
+ while (var4.hasNext()) {
|
|
|
+ Integer key = (Integer) var4.next();
|
|
|
cell = row.createCell(key);
|
|
|
- cell.setCellStyle((CellStyle)this.styles.get("total"));
|
|
|
+ cell.setCellStyle((CellStyle) this.styles.get("total"));
|
|
|
cell.setCellValue(DOUBLE_FORMAT.format(this.statistics.get(key)));
|
|
|
}
|
|
|
|
|
@@ -719,7 +636,7 @@ public class ExcelUtilImage<T> {
|
|
|
String[] var7 = targets;
|
|
|
int var8 = targets.length;
|
|
|
|
|
|
- for(int var9 = 0; var9 < var8; ++var9) {
|
|
|
+ for (int var9 = 0; var9 < var8; ++var9) {
|
|
|
String name = var7[var9];
|
|
|
o = this.getValue(o, name);
|
|
|
}
|
|
@@ -744,8 +661,8 @@ public class ExcelUtilImage<T> {
|
|
|
|
|
|
private void createExcelField() {
|
|
|
this.fields = this.getFields();
|
|
|
- this.fields = (List)this.fields.stream().sorted(Comparator.comparing((objects) -> {
|
|
|
- return ((Excel)objects[1]).sort();
|
|
|
+ this.fields = (List) this.fields.stream().sorted(Comparator.comparing((objects) -> {
|
|
|
+ return ((Excel) objects[1]).sort();
|
|
|
})).collect(Collectors.toList());
|
|
|
this.maxHeight = this.getRowHeight();
|
|
|
}
|
|
@@ -757,29 +674,29 @@ public class ExcelUtilImage<T> {
|
|
|
tempFields.addAll(Arrays.asList(this.clazz.getDeclaredFields()));
|
|
|
Iterator var3 = tempFields.iterator();
|
|
|
|
|
|
- while(true) {
|
|
|
+ while (true) {
|
|
|
Field field;
|
|
|
do {
|
|
|
if (!var3.hasNext()) {
|
|
|
return fields;
|
|
|
}
|
|
|
|
|
|
- field = (Field)var3.next();
|
|
|
+ field = (Field) var3.next();
|
|
|
if (field.isAnnotationPresent(Excel.class)) {
|
|
|
- Excel attr = (Excel)field.getAnnotation(Excel.class);
|
|
|
+ Excel attr = (Excel) field.getAnnotation(Excel.class);
|
|
|
if (attr != null && (attr.type() == Type.ALL || attr.type() == this.type)) {
|
|
|
field.setAccessible(true);
|
|
|
fields.add(new Object[]{field, attr});
|
|
|
}
|
|
|
}
|
|
|
- } while(!field.isAnnotationPresent(Excels.class));
|
|
|
+ } while (!field.isAnnotationPresent(Excels.class));
|
|
|
|
|
|
- Excels attrs = (Excels)field.getAnnotation(Excels.class);
|
|
|
+ Excels attrs = (Excels) field.getAnnotation(Excels.class);
|
|
|
Excel[] excels = attrs.value();
|
|
|
Excel[] var7 = excels;
|
|
|
int var8 = excels.length;
|
|
|
|
|
|
- for(int var9 = 0; var9 < var8; ++var9) {
|
|
|
+ for (int var9 = 0; var9 < var8; ++var9) {
|
|
|
Excel attr = var7[var9];
|
|
|
if (attr != null && (attr.type() == Type.ALL || attr.type() == this.type)) {
|
|
|
field.setAccessible(true);
|
|
@@ -793,12 +710,12 @@ public class ExcelUtilImage<T> {
|
|
|
double maxHeight = 0.0D;
|
|
|
|
|
|
Excel excel;
|
|
|
- for(Iterator var3 = this.fields.iterator(); var3.hasNext(); maxHeight = Math.max(maxHeight, excel.height())) {
|
|
|
- Object[] os = (Object[])var3.next();
|
|
|
- excel = (Excel)os[1];
|
|
|
+ for (Iterator var3 = this.fields.iterator(); var3.hasNext(); maxHeight = Math.max(maxHeight, excel.height())) {
|
|
|
+ Object[] os = (Object[]) var3.next();
|
|
|
+ excel = (Excel) os[1];
|
|
|
}
|
|
|
|
|
|
- return (short)((int)(maxHeight * 20.0D));
|
|
|
+ return (short) ((int) (maxHeight * 20.0D));
|
|
|
}
|
|
|
|
|
|
public void createWorkbook() {
|
|
@@ -837,8 +754,8 @@ public class ExcelUtilImage<T> {
|
|
|
} else {
|
|
|
val = cell.getNumericCellValue();
|
|
|
if (DateUtil.isCellDateFormatted(cell)) {
|
|
|
- val = DateUtil.getJavaDate((Double)val);
|
|
|
- } else if ((Double)val % 1.0D != 0.0D) {
|
|
|
+ val = DateUtil.getJavaDate((Double) val);
|
|
|
+ } else if ((Double) val % 1.0D != 0.0D) {
|
|
|
val = new BigDecimal(val.toString());
|
|
|
} else {
|
|
|
val = (new DecimalFormat("0")).format(val);
|
|
@@ -857,7 +774,7 @@ public class ExcelUtilImage<T> {
|
|
|
if (row == null) {
|
|
|
return true;
|
|
|
} else {
|
|
|
- for(int i = row.getFirstCellNum(); i < row.getLastCellNum(); ++i) {
|
|
|
+ for (int i = row.getFirstCellNum(); i < row.getLastCellNum(); ++i) {
|
|
|
Cell cell = row.getCell(i);
|
|
|
if (cell != null && cell.getCellType() != CellType.BLANK) {
|
|
|
return false;
|
|
@@ -874,11 +791,11 @@ public class ExcelUtilImage<T> {
|
|
|
} else {
|
|
|
String str;
|
|
|
if (val instanceof Date) {
|
|
|
- str = DateUtils.parseDateToStr(dateFormat, (Date)val);
|
|
|
+ str = DateUtils.parseDateToStr(dateFormat, (Date) val);
|
|
|
} else if (val instanceof LocalDateTime) {
|
|
|
- str = DateUtils.parseDateToStr(dateFormat, DateUtils.toDate((LocalDateTime)val));
|
|
|
+ str = DateUtils.parseDateToStr(dateFormat, DateUtils.toDate((LocalDateTime) val));
|
|
|
} else if (val instanceof LocalDate) {
|
|
|
- str = DateUtils.parseDateToStr(dateFormat, DateUtils.toDate((LocalDate)val));
|
|
|
+ str = DateUtils.parseDateToStr(dateFormat, DateUtils.toDate((LocalDate) val));
|
|
|
} else {
|
|
|
str = val.toString();
|
|
|
}
|