setCellTypepublic void setCellType(int cellType) Set the cells type (numeric, formula or string) Specified by: setCellType in interface Cell Throws: java.lang.IllegalArgumentException - if the specified cell type is invalid See Also: Cell.CELL_TYPE_NUMERIC, Cell.CELL_TYPE_STRING, Cell.CELL_TYPE_FORMULA, Cell.CELL_TYPE_BLANK, Cell.CELL_TYPE_BOOLEAN, Cell.CELL_TYPE_ERROR没发现有日期格式,日期格式化字符串传吧- -
单元格0,0 已经手动设为日期格式-- FileInputStream fin = new FileInputStream(xlsx0); Workbook wb = new XSSFWorkbook(fin);
选中excel的某个已经存在的数据的区域,例如是A7:B12 (12是已经使用的行数)。并且设置为日期格式yyyy-m-d。
求解决方案的代码。。
所以我改用poi直接操作,但就卡在这里:选中excel的数据的区域 A7:B12 (12是已经使用的行数)。并且设置为日期格式yyyy-m-d。
Set the cells type (numeric, formula or string)
Specified by:
setCellType in interface Cell
Throws:
java.lang.IllegalArgumentException - if the specified cell type is invalid
See Also:
Cell.CELL_TYPE_NUMERIC, Cell.CELL_TYPE_STRING, Cell.CELL_TYPE_FORMULA, Cell.CELL_TYPE_BLANK, Cell.CELL_TYPE_BOOLEAN, Cell.CELL_TYPE_ERROR没发现有日期格式,日期格式化字符串传吧- -
FileInputStream fin = new FileInputStream(xlsx0);
Workbook wb = new XSSFWorkbook(fin);
Sheet sheet = wb.getSheetAt(0);
Row row = sheet.getRow(0);
Cell cell = row.getCell(0);
System.out.println(cell.getCellType());结果为:0 代表:Cell.CELL_TYPE_NUMERIC
so 楼主自己看着办吧
就像图中,我要将A2:A7区域的原本格式yyyy-mm-dd h:mm转换成yyyy-m-d,
java哪种技术可以实现,poi或者jxl可以吗?
java哪种技术可以实现,poi或者jxl可以吗?
SimpleDateFormat df = new SimpleDateFormat("yyyy-m-d");
Date date = null;
try {
date = df.parse(oDateStr);
} catch (Exception e) {
}对你来说应该就是时间格式化的问题,你看看java时间格式化不就完了啊