mirror of
https://gitee.com/dromara/hutool.git
synced 2025-05-04 12:47:59 +08:00
compated to poi 5.x
This commit is contained in:
parent
dfbbd7c6c1
commit
b285db71cd
@ -6,6 +6,7 @@
|
|||||||
# 5.6.0 (2021-02-27)
|
# 5.6.0 (2021-02-27)
|
||||||
|
|
||||||
### 新特性
|
### 新特性
|
||||||
|
* 【poi 】 重要:不再兼容POI-3.x,增加兼容POI-5.x(issue#I35J6B@Gitee)
|
||||||
|
|
||||||
### Bug修复
|
### Bug修复
|
||||||
|
|
||||||
|
@ -7,7 +7,6 @@ import cn.hutool.poi.excel.ExcelDateUtil;
|
|||||||
import cn.hutool.poi.excel.ExcelUtil;
|
import cn.hutool.poi.excel.ExcelUtil;
|
||||||
import cn.hutool.poi.excel.StyleSet;
|
import cn.hutool.poi.excel.StyleSet;
|
||||||
import cn.hutool.poi.excel.editors.TrimEditor;
|
import cn.hutool.poi.excel.editors.TrimEditor;
|
||||||
|
|
||||||
import org.apache.poi.ss.usermodel.Cell;
|
import org.apache.poi.ss.usermodel.Cell;
|
||||||
import org.apache.poi.ss.usermodel.CellStyle;
|
import org.apache.poi.ss.usermodel.CellStyle;
|
||||||
import org.apache.poi.ss.usermodel.CellType;
|
import org.apache.poi.ss.usermodel.CellType;
|
||||||
@ -39,7 +38,6 @@ import java.util.Date;
|
|||||||
* @author looly
|
* @author looly
|
||||||
* @since 4.0.7
|
* @since 4.0.7
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
public class CellUtil {
|
public class CellUtil {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -64,7 +62,7 @@ public class CellUtil {
|
|||||||
if (null == cell) {
|
if (null == cell) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return getCellValue(cell, cell.getCellTypeEnum(), isTrimCellValue);
|
return getCellValue(cell, cell.getCellType(), isTrimCellValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -107,14 +105,14 @@ public class CellUtil {
|
|||||||
return null == cellEditor ? null : cellEditor.edit(cell, null);
|
return null == cellEditor ? null : cellEditor.edit(cell, null);
|
||||||
}
|
}
|
||||||
if (null == cellType) {
|
if (null == cellType) {
|
||||||
cellType = cell.getCellTypeEnum();
|
cellType = cell.getCellType();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 尝试获取合并单元格,如果是合并单元格,则重新获取单元格类型
|
// 尝试获取合并单元格,如果是合并单元格,则重新获取单元格类型
|
||||||
final Cell mergedCell = getMergedRegionCell(cell);
|
final Cell mergedCell = getMergedRegionCell(cell);
|
||||||
if (mergedCell != cell) {
|
if (mergedCell != cell) {
|
||||||
cell = mergedCell;
|
cell = mergedCell;
|
||||||
cellType = cell.getCellTypeEnum();
|
cellType = cell.getCellType();
|
||||||
}
|
}
|
||||||
|
|
||||||
Object value;
|
Object value;
|
||||||
@ -127,7 +125,7 @@ public class CellUtil {
|
|||||||
break;
|
break;
|
||||||
case FORMULA:
|
case FORMULA:
|
||||||
// 遇到公式时查找公式结果类型
|
// 遇到公式时查找公式结果类型
|
||||||
value = getCellValue(cell, cell.getCachedFormulaResultTypeEnum(), cellEditor);
|
value = getCellValue(cell, cell.getCachedFormulaResultType(), cellEditor);
|
||||||
break;
|
break;
|
||||||
case BLANK:
|
case BLANK:
|
||||||
value = StrUtil.EMPTY;
|
value = StrUtil.EMPTY;
|
||||||
@ -332,10 +330,10 @@ public class CellUtil {
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (null != cellStyle) {
|
if (null != cellStyle) {
|
||||||
RegionUtil.setBorderTop(cellStyle.getBorderTopEnum(), cellRangeAddress, sheet);
|
RegionUtil.setBorderTop(cellStyle.getBorderTop(), cellRangeAddress, sheet);
|
||||||
RegionUtil.setBorderRight(cellStyle.getBorderRightEnum(), cellRangeAddress, sheet);
|
RegionUtil.setBorderRight(cellStyle.getBorderRight(), cellRangeAddress, sheet);
|
||||||
RegionUtil.setBorderBottom(cellStyle.getBorderBottomEnum(), cellRangeAddress, sheet);
|
RegionUtil.setBorderBottom(cellStyle.getBorderBottom(), cellRangeAddress, sheet);
|
||||||
RegionUtil.setBorderLeft(cellStyle.getBorderLeftEnum(), cellRangeAddress, sheet);
|
RegionUtil.setBorderLeft(cellStyle.getBorderLeft(), cellRangeAddress, sheet);
|
||||||
}
|
}
|
||||||
return sheet.addMergedRegion(cellRangeAddress);
|
return sheet.addMergedRegion(cellRangeAddress);
|
||||||
}
|
}
|
||||||
|
@ -73,7 +73,6 @@ public class NullCell implements Cell {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public CellType getCellTypeEnum() {
|
public CellType getCellTypeEnum() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -83,7 +82,6 @@ public class NullCell implements Cell {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public CellType getCachedFormulaResultTypeEnum() {
|
public CellType getCachedFormulaResultTypeEnum() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -85,8 +85,7 @@ public class ExcelSaxUtil {
|
|||||||
case SSTINDEX:
|
case SSTINDEX:
|
||||||
try {
|
try {
|
||||||
final int index = Integer.parseInt(value);
|
final int index = Integer.parseInt(value);
|
||||||
//noinspection deprecation
|
result = sharedStringsTable.getItemAt(index).getString();
|
||||||
result = new XSSFRichTextString(sharedStringsTable.getEntryAt(index)).getString();
|
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
result = value;
|
result = value;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user