|
@@ -268,7 +268,7 @@ public class ExcelUtilImage<T> {
|
|
|
public void exportExcel(HttpServletResponse response) {
|
|
|
try {
|
|
|
this.writeSheet();
|
|
|
- this.addSignatureAndDate(this.sheet); // 在写入数据后添加签名和日期
|
|
|
+ this.addSignatureAndDate(this.sheet); // 写入数据后添加签名和日期
|
|
|
this.wb.write(response.getOutputStream());
|
|
|
} catch (Exception var6) {
|
|
|
log.error("导出Excel异常{}", var6.getMessage());
|
|
@@ -468,6 +468,8 @@ public class ExcelUtilImage<T> {
|
|
|
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
public Cell addCell(Excel attr, Row row, T vo, Field field, int column) {
|
|
|
Cell cell = null;
|
|
|
|
|
@@ -478,6 +480,15 @@ public class ExcelUtilImage<T> {
|
|
|
int align = attr.align().value();
|
|
|
cell.setCellStyle((CellStyle)this.styles.get("data" + (align >= 1 && align <= 3 ? align : "")));
|
|
|
Object value = this.getTargetValue(vo, field, attr);
|
|
|
+ if(value instanceof List) {
|
|
|
+ List listValue = (List) value;
|
|
|
+ for(int i = 0; i < listValue.size(); i++) {
|
|
|
+ Cell newCell = row.createCell(column + i);
|
|
|
+ newCell.setCellStyle((CellStyle)this.styles.get("data" + (align >= 1 && align <= 3 ? align : "")));
|
|
|
+ Object elementValue = listValue.get(i);
|
|
|
+ newCell.setCellValue(elementValue.toString());
|
|
|
+ }
|
|
|
+ }
|
|
|
String dateFormat = attr.dateFormat();
|
|
|
String readConverterExp = attr.readConverterExp();
|
|
|
String separator = attr.separator();
|
|
@@ -502,6 +513,40 @@ public class ExcelUtilImage<T> {
|
|
|
return cell;
|
|
|
}
|
|
|
|
|
|
+/* public Cell addCell(Excel attr, Row row, T vo, Field field, int column) {
|
|
|
+ Cell cell = null;
|
|
|
+
|
|
|
+ try {
|
|
|
+ row.setHeight(this.maxHeight);
|
|
|
+ if (attr.isExport()) {
|
|
|
+ cell = row.createCell(column);
|
|
|
+ int align = attr.align().value();
|
|
|
+ cell.setCellStyle((CellStyle)this.styles.get("data" + (align >= 1 && align <= 3 ? align : "")));
|
|
|
+ Object value = this.getTargetValue(vo, field, attr);
|
|
|
+ String dateFormat = attr.dateFormat();
|
|
|
+ String readConverterExp = attr.readConverterExp();
|
|
|
+ String separator = attr.separator();
|
|
|
+ if (StringUtils.isNotEmpty(dateFormat) && StringUtils.isNotNull(value)) {
|
|
|
+ cell.setCellValue(this.parseDateToStr(dateFormat, value));
|
|
|
+ } else if (StringUtils.isNotEmpty(readConverterExp) && StringUtils.isNotNull(value)) {
|
|
|
+ cell.setCellValue(convertByExp(Convert.toStr(value), readConverterExp, separator));
|
|
|
+ } else if (value instanceof BigDecimal && -1 != attr.scale()) {
|
|
|
+ cell.setCellValue(((BigDecimal)value).setScale(attr.scale(), attr.roundingMode()).toString());
|
|
|
+ } else if (!attr.handler().equals(ExcelHandlerAdapter.class)) {
|
|
|
+ cell.setCellValue(this.dataFormatHandlerAdapter(value, attr));
|
|
|
+ } else {
|
|
|
+ this.setCellVo(value, attr, cell);
|
|
|
+ }
|
|
|
+
|
|
|
+ this.addStatisticsData(column, Convert.toStr(value), attr);
|
|
|
+ }
|
|
|
+ } catch (Exception var12) {
|
|
|
+ log.error("导出Excel失败{}", var12);
|
|
|
+ }
|
|
|
+
|
|
|
+ return cell;
|
|
|
+ }*/
|
|
|
+
|
|
|
public void setPromptOrValidation(Sheet sheet, String[] textlist, String promptContent, int firstRow, int endRow, int firstCol, int endCol) {
|
|
|
DataValidationHelper helper = sheet.getDataValidationHelper();
|
|
|
DataValidationConstraint constraint = textlist.length > 0 ? helper.createExplicitListConstraint(textlist) : helper.createCustomConstraint("DD1");
|