汇总:https://www.cnblogs.com/liufei-kuaile/p/7359609.html
JXL:https://blog.csdn.net/u013041642/article/details/72824360
1、removeRow(Row row):删除行,但不会实现下面行上移
2、shiftRows(int startRow, int endRow, n):start行到end行移动n行,n正上移,n负下移。合并过单元格的移动会报错
3、removeMergedRegion(int deleRow):删除样式
4、表、行、单元格循环的时候都是从0开始读
5、shiftRows无法向上移动,个人猜测,removeRow删除行只有在write方法调用后才生效,所以上移会出现合并的单元格无法移动。
public void func(Workbook wb) {
for (int i = 0; i < wb.getNumberOfSheets(); i++) {
Sheet sheet = wb.getSheetAt(i);
for (int rr = 0; rr < sheet.getPhysicalNumberOfRows(); rr++) { // 遍历有记录的所有行,空行不记录
Row row = sheet.getRow(rr);
if (row == null) {
continue;
}
for (int cc = 0; cc < row.getPhysicalNumberOfCells(); cc++) { // 遍历所有列,空列不记录
Cell cell = row.getCell(cc);
CellType cellType = cell.getCellTypeEnum();
String value;
switch (cellType) {
case STRING:
value = cell.getStringCellValue();
case NUMERIC:
value = String.valueOf(cell.getNumericCellValue());
case BOOLEAN:
value = String.valueOf(cell.getBooleanCellValue());
default:
value = "";
}
cell.setCellValue(value);
}
}
}
}
二、关于POI3.17的一些问题
1、使用poi3.17版本生成excel的一些样式设置http://blog.sina.com.cn/s/blog_c2aff7060102xlj4.html
2、不推荐getCellType(),推荐getCellTypeEnum()
3、POI使用详解h