|
|
@@ -1,12 +1,12 @@
|
|
|
package com.zd.common.core.utils;
|
|
|
|
|
|
+import com.zd.common.core.utils.file.FileTypeUtils;
|
|
|
+import com.zd.common.core.utils.file.ImageUtils;
|
|
|
import com.zd.common.core.utils.reflect.ReflectUtils;
|
|
|
import com.zd.model.annotation.Excel;
|
|
|
import com.zd.model.annotation.Excel.ColumnType;
|
|
|
import com.zd.model.annotation.Excel.Type;
|
|
|
import com.zd.model.annotation.Excels;
|
|
|
-import com.zd.common.core.utils.file.FileTypeUtils;
|
|
|
-import com.zd.common.core.utils.file.ImageUtils;
|
|
|
import org.apache.poi.ss.usermodel.*;
|
|
|
import org.apache.poi.ss.util.CellRangeAddress;
|
|
|
import org.apache.poi.ss.util.CellRangeAddressList;
|
|
|
@@ -16,6 +16,7 @@ import org.apache.poi.xssf.usermodel.XSSFClientAnchor;
|
|
|
import org.apache.poi.xssf.usermodel.XSSFDataValidation;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
+
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
import java.io.IOException;
|
|
|
import java.io.InputStream;
|
|
|
@@ -560,6 +561,7 @@ public class ExcelUtil<T> {
|
|
|
*/
|
|
|
public void setCellVo(Object value, Excel attr, Cell cell) {
|
|
|
if (ColumnType.STRING == attr.cellType()) {
|
|
|
+
|
|
|
cell.setCellValue(StringUtils.isNull(value) ? attr.defaultValue() : value + attr.suffix());
|
|
|
} else if (ColumnType.NUMERIC == attr.cellType()) {
|
|
|
if (StringUtils.isNotNull(value)) {
|
|
|
@@ -945,6 +947,10 @@ public class ExcelUtil<T> {
|
|
|
} else {
|
|
|
wb.setSheetName(index, sheetName + index);
|
|
|
}
|
|
|
+ CellStyle style = wb.createCellStyle();
|
|
|
+ DataFormat format = wb.createDataFormat();
|
|
|
+ style.setDataFormat(format.getFormat("@"));
|
|
|
+ sheet.setDefaultColumnStyle(index, style);
|
|
|
}
|
|
|
|
|
|
/**
|