各种优化修复
This commit is contained in:
@@ -245,7 +245,7 @@ public class ExcelExport {
|
||||
* @param groups 导入分组
|
||||
*/
|
||||
public void createSheet(String sheetName, String title, List<String> headerList, List<Integer> headerWidthList) {
|
||||
this.sheet = wb.createSheet(StringUtils.defaultString(sheetName, "Export"));
|
||||
this.sheet = wb.createSheet(StringUtils.defaultString(sheetName, StringUtils.defaultString(title, "Sheet1")));
|
||||
this.styles = createStyles(wb);
|
||||
// Create title
|
||||
if (StringUtils.isNotBlank(title)){
|
||||
@@ -271,6 +271,8 @@ public class ExcelExport {
|
||||
cell.setCellValue(ss[0]);
|
||||
Comment comment = this.sheet.createDrawingPatriarch().createCellComment(
|
||||
new XSSFClientAnchor(0, 0, 0, 0, (short) 3, 3, (short) 5, 6));
|
||||
comment.setRow(cell.getRowIndex());
|
||||
comment.setColumn(cell.getColumnIndex());
|
||||
comment.setString(new XSSFRichTextString(ss[1]));
|
||||
cell.setCellComment(comment);
|
||||
}else{
|
||||
|
||||
@@ -15,6 +15,7 @@ import java.util.Comparator;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.poi.hssf.usermodel.HSSFDateUtil;
|
||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
|
||||
import org.apache.poi.ss.formula.eval.ErrorEval;
|
||||
@@ -232,7 +233,12 @@ public class ExcelImport {
|
||||
Cell cell = row.getCell(column);
|
||||
if (cell != null){
|
||||
if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC){
|
||||
val = new DecimalFormat("0").format(cell.getNumericCellValue());
|
||||
val = cell.getNumericCellValue();
|
||||
if (HSSFDateUtil.isCellDateFormatted(cell)) {
|
||||
val = DateUtil.getJavaDate((Double)val); // POI Excel 日期格式转换
|
||||
}else{
|
||||
val = new DecimalFormat("0").format(val);
|
||||
}
|
||||
}else if (cell.getCellType() == Cell.CELL_TYPE_STRING){
|
||||
val = cell.getStringCellValue();
|
||||
}else if (cell.getCellType() == Cell.CELL_TYPE_FORMULA){
|
||||
@@ -399,9 +405,8 @@ public class ExcelImport {
|
||||
}else if (valType == Date.class){
|
||||
if (val instanceof String){
|
||||
val = DateUtils.parseDate(val);
|
||||
}else{
|
||||
// POI Excel 日期格式转换
|
||||
val = DateUtil.getJavaDate((Double)val);
|
||||
}else if (val instanceof Double){
|
||||
val = DateUtil.getJavaDate((Double)val); // POI Excel 日期格式转换
|
||||
}
|
||||
}else{
|
||||
if (ef.fieldType() != Class.class){
|
||||
|
||||
Reference in New Issue
Block a user