Commit 22eac10b authored by 季圣华's avatar 季圣华
Browse files

优化excel工具类

parent d3536646
package com.jsh.erp.utils;
import java.io.File;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.text.SimpleDateFormat;
import java.util.*;
import jxl.*;
import org.springframework.util.StringUtils;
import jxl.Cell;
import jxl.Sheet;
import jxl.Workbook;
import jxl.format.*;
import jxl.write.Label;
import jxl.write.WritableCellFormat;
......@@ -211,6 +207,21 @@ public class ExcelUtils {
}
}
public static String getDateContent(Sheet src, int rowNum, int colNum) {
// 日期 类型的处理
Cell c = src.getRow(rowNum)[colNum];
if(CellType.DATE.equals(c.getType())) {
DateCell dc = (DateCell) c;
Date jxlDate = dc.getDate();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
return sdf.format(jxlDate);
} else {
String dateStr = c.getContents().trim();
return dateStr;
}
}
/**
* 从第i行开始到最后检测指定列的唯一性
*
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment