T - 子类类型,用于返回thispublic class ExcelBase<T extends ExcelBase<T>> extends Object implements Closeable
| Modifier and Type | Field and Description |
|---|---|
protected boolean |
isClosed
是否被关闭
|
protected org.apache.poi.ss.usermodel.Sheet |
sheet
Excel中对应的Sheet
|
protected org.apache.poi.ss.usermodel.Workbook |
workbook
工作簿
|
| Constructor and Description |
|---|
ExcelBase(org.apache.poi.ss.usermodel.Sheet sheet)
构造
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
关闭工作簿
如果用户设定了目标文件,先写出目标文件后给关闭工作簿
|
org.apache.poi.ss.usermodel.CellStyle |
createCellStyle(int x,
int y)
为指定单元格创建样式,返回样式后可以设置样式内容
|
org.apache.poi.ss.usermodel.CellStyle |
createCellStyle(String locationRef)
为指定单元格创建样式,返回样式后可以设置样式内容
|
org.apache.poi.ss.usermodel.Cell |
getCell(int x,
int y)
获取指定坐标单元格,单元格不存在时返回
null |
org.apache.poi.ss.usermodel.Cell |
getCell(int x,
int y,
boolean isCreateIfNotExist)
获取指定坐标单元格,如果isCreateIfNotExist为false,则在单元格不存在时返回
null |
org.apache.poi.ss.usermodel.Cell |
getCell(String locationRef)
获取指定坐标单元格,单元格不存在时返回
null |
org.apache.poi.ss.usermodel.Cell |
getCell(String locationRef,
boolean isCreateIfNotExist)
获取指定坐标单元格,如果isCreateIfNotExist为false,则在单元格不存在时返回
null |
int |
getColumnCount()
获取第一行总列数,计算方法为:
|
int |
getColumnCount(int rowNum)
获取总列数,计算方法为:
|
org.apache.poi.ss.usermodel.Cell |
getOrCreateCell(int x,
int y)
获取或创建指定坐标单元格
|
org.apache.poi.ss.usermodel.Cell |
getOrCreateCell(String locationRef)
获取或创建指定坐标单元格
|
org.apache.poi.ss.usermodel.CellStyle |
getOrCreateCellStyle(int x,
int y)
为指定单元格获取或者创建样式,返回样式后可以设置样式内容
|
org.apache.poi.ss.usermodel.CellStyle |
getOrCreateCellStyle(String locationRef)
为指定单元格获取或者创建样式,返回样式后可以设置样式内容
|
org.apache.poi.ss.usermodel.CellStyle |
getOrCreateColumnStyle(int x)
获取或创建某一行的样式,返回样式后可以设置样式内容
|
org.apache.poi.ss.usermodel.Row |
getOrCreateRow(int y)
获取或者创建行
|
org.apache.poi.ss.usermodel.CellStyle |
getOrCreateRowStyle(int y)
获取或创建某一行的样式,返回样式后可以设置样式内容
|
int |
getPhysicalRowCount()
获取有记录的行数,计算方法为:
|
int |
getRowCount()
获取总行数,计算方法为:
|
org.apache.poi.ss.usermodel.Sheet |
getSheet()
获取当前Sheet
|
int |
getSheetCount()
返回工作簿表格数
|
List<String> |
getSheetNames()
获取表名列表
|
List<org.apache.poi.ss.usermodel.Sheet> |
getSheets()
获取此工作簿所有Sheet表
|
org.apache.poi.ss.usermodel.Workbook |
getWorkbook()
获取Workbook
|
T |
setSheet(int sheetIndex)
自定义需要读取或写出的Sheet,如果给定的sheet不存在,创建之(命名为默认)
在读取中,此方法用于切换读取的sheet,在写出时,此方法用于新建或者切换sheet
|
T |
setSheet(String sheetName)
自定义需要读取或写出的Sheet,如果给定的sheet不存在,创建之
在读取中,此方法用于切换读取的sheet,在写出时,此方法用于新建或者切换sheet
|
protected boolean isClosed
protected org.apache.poi.ss.usermodel.Workbook workbook
protected org.apache.poi.ss.usermodel.Sheet sheet
public ExcelBase(org.apache.poi.ss.usermodel.Sheet sheet)
sheet - Excel中的sheetpublic org.apache.poi.ss.usermodel.Workbook getWorkbook()
public int getSheetCount()
public List<org.apache.poi.ss.usermodel.Sheet> getSheets()
public org.apache.poi.ss.usermodel.Sheet getSheet()
Sheetpublic T setSheet(String sheetName)
sheetName - sheet名public T setSheet(int sheetIndex)
sheetIndex - sheet序号,从0开始计数public org.apache.poi.ss.usermodel.Cell getCell(int x,
int y)
nullx - X坐标,从0计数,既列号y - Y坐标,从0计数,既行号Cellpublic org.apache.poi.ss.usermodel.Cell getCell(String locationRef)
nulllocationRef - 单元格地址标识符,例如A11,B5Cellpublic org.apache.poi.ss.usermodel.Cell getOrCreateCell(int x,
int y)
x - X坐标,从0计数,既列号y - Y坐标,从0计数,既行号Cellpublic org.apache.poi.ss.usermodel.Cell getOrCreateCell(String locationRef)
locationRef - 单元格地址标识符,例如A11,B5Cellpublic org.apache.poi.ss.usermodel.Cell getCell(int x,
int y,
boolean isCreateIfNotExist)
nullx - X坐标,从0计数,既列号y - Y坐标,从0计数,既行号isCreateIfNotExist - 单元格不存在时是否创建Cellpublic org.apache.poi.ss.usermodel.Cell getCell(String locationRef, boolean isCreateIfNotExist)
nulllocationRef - 单元格地址标识符,例如A11,B5isCreateIfNotExist - 单元格不存在时是否创建Cellpublic org.apache.poi.ss.usermodel.Row getOrCreateRow(int y)
y - Y坐标,从0计数,既行号Rowpublic org.apache.poi.ss.usermodel.CellStyle getOrCreateCellStyle(int x,
int y)
x - X坐标,从0计数,既列号y - Y坐标,从0计数,既行号CellStylepublic org.apache.poi.ss.usermodel.CellStyle getOrCreateRowStyle(int y)
y - Y坐标,从0计数,既行号CellStylepublic org.apache.poi.ss.usermodel.CellStyle getOrCreateCellStyle(String locationRef)
locationRef - 单元格地址标识符,例如A11,B5CellStylepublic org.apache.poi.ss.usermodel.CellStyle getOrCreateColumnStyle(int x)
x - X坐标,从0计数,既列号CellStylepublic org.apache.poi.ss.usermodel.CellStyle createCellStyle(int x,
int y)
x - X坐标,从0计数,即列号y - Y坐标,从0计数,即行号CellStylepublic org.apache.poi.ss.usermodel.CellStyle createCellStyle(String locationRef)
locationRef - 单元格地址标识符,例如A11,B5CellStylepublic int getRowCount()
最后一行序号 + 1
public int getPhysicalRowCount()
最后一行序号 - 第一行序号 + 1
public int getColumnCount()
最后一列序号 + 1
public int getColumnCount(int rowNum)
最后一列序号 + 1
rowNum - 行号public void close()
close in interface Closeableclose in interface AutoCloseableCopyright © 2020. All rights reserved.