public class CellUtil extends Object
| Constructor and Description |
|---|
CellUtil() |
| Modifier and Type | Method and Description |
|---|---|
static Object |
getCellValue(org.apache.poi.ss.usermodel.Cell cell)
获取单元格值
|
static Object |
getCellValue(org.apache.poi.ss.usermodel.Cell cell,
boolean isTrimCellValue)
获取单元格值
|
static Object |
getCellValue(org.apache.poi.ss.usermodel.Cell cell,
CellEditor cellEditor)
获取单元格值
|
static Object |
getCellValue(org.apache.poi.ss.usermodel.Cell cell,
org.apache.poi.ss.usermodel.CellType cellType,
boolean isTrimCellValue)
获取单元格值
|
static Object |
getCellValue(org.apache.poi.ss.usermodel.Cell cell,
org.apache.poi.ss.usermodel.CellType cellType,
CellEditor cellEditor)
获取单元格值
如果单元格值为数字格式,则判断其格式中是否有小数部分,无则返回Long类型,否则返回Double类型 |
static Object |
getMergedRegionValue(org.apache.poi.ss.usermodel.Sheet sheet,
int x,
int y)
获取合并单元格的值
传入的x,y坐标(列行数)可以是合并单元格范围内的任意一个单元格 |
static org.apache.poi.ss.usermodel.Cell |
getOrCreateCell(org.apache.poi.ss.usermodel.Row row,
int cellIndex)
获取已有行或创建新行
|
static boolean |
isMergedRegion(org.apache.poi.ss.usermodel.Sheet sheet,
int row,
int column)
判断指定的单元格是否是合并单元格
|
static int |
mergingCells(org.apache.poi.ss.usermodel.Sheet sheet,
int firstRow,
int lastRow,
int firstColumn,
int lastColumn,
org.apache.poi.ss.usermodel.CellStyle cellStyle)
合并单元格,可以根据设置的值来合并行和列
|
static void |
setCellValue(org.apache.poi.ss.usermodel.Cell cell,
Object value,
org.apache.poi.ss.usermodel.CellStyle style)
设置单元格值
根据传入的styleSet自动匹配样式 当为头部样式时默认赋值头部样式,但是头部中如果有数字、日期等类型,将按照数字、日期样式设置 |
static void |
setCellValue(org.apache.poi.ss.usermodel.Cell cell,
Object value,
StyleSet styleSet,
boolean isHeader)
设置单元格值
根据传入的styleSet自动匹配样式 当为头部样式时默认赋值头部样式,但是头部中如果有数字、日期等类型,将按照数字、日期样式设置 |
public static Object getCellValue(org.apache.poi.ss.usermodel.Cell cell)
cell - Cell单元格public static Object getCellValue(org.apache.poi.ss.usermodel.Cell cell, boolean isTrimCellValue)
cell - Cell单元格isTrimCellValue - 如果单元格类型为字符串,是否去掉两边空白符public static Object getCellValue(org.apache.poi.ss.usermodel.Cell cell, CellEditor cellEditor)
cell - Cell单元格cellEditor - 单元格值编辑器。可以通过此编辑器对单元格值做自定义操作public static Object getCellValue(org.apache.poi.ss.usermodel.Cell cell, org.apache.poi.ss.usermodel.CellType cellType, boolean isTrimCellValue)
cell - Cell单元格cellType - 单元格值类型CellType枚举isTrimCellValue - 如果单元格类型为字符串,是否去掉两边空白符public static Object getCellValue(org.apache.poi.ss.usermodel.Cell cell, org.apache.poi.ss.usermodel.CellType cellType, CellEditor cellEditor)
cell - Cell单元格cellType - 单元格值类型CellType枚举,如果为null默认使用cell的类型cellEditor - 单元格值编辑器。可以通过此编辑器对单元格值做自定义操作public static void setCellValue(org.apache.poi.ss.usermodel.Cell cell,
Object value,
StyleSet styleSet,
boolean isHeader)
cell - 单元格value - 值styleSet - 单元格样式集,包括日期等样式isHeader - 是否为标题单元格public static void setCellValue(org.apache.poi.ss.usermodel.Cell cell,
Object value,
org.apache.poi.ss.usermodel.CellStyle style)
cell - 单元格value - 值style - 自定义样式,null表示无样式public static org.apache.poi.ss.usermodel.Cell getOrCreateCell(org.apache.poi.ss.usermodel.Row row,
int cellIndex)
row - Excel表的行cellIndex - 列号Rowpublic static boolean isMergedRegion(org.apache.poi.ss.usermodel.Sheet sheet,
int row,
int column)
sheet - Sheetrow - 行号column - 列号public static int mergingCells(org.apache.poi.ss.usermodel.Sheet sheet,
int firstRow,
int lastRow,
int firstColumn,
int lastColumn,
org.apache.poi.ss.usermodel.CellStyle cellStyle)
sheet - 表对象firstRow - 起始行,0开始lastRow - 结束行,0开始firstColumn - 起始列,0开始lastColumn - 结束列,0开始cellStyle - 单元格样式,只提取边框样式public static Object getMergedRegionValue(org.apache.poi.ss.usermodel.Sheet sheet, int x, int y)
sheet - Sheety - 行号,从0开始,可以是合并单元格范围中的任意一行x - 列号,从0开始,可以是合并单元格范围中的任意一列Copyright © 2021. All rights reserved.