@TopNS(prefix={"","r"}, value="worksheet", uri={"http://schemas.openxmlformats.org/spreadsheetml/2006/main","http://schemas.openxmlformats.org/officeDocument/2006/relationships"}) public abstract class Sheet extends Object implements Cloneable, Storable
Usually worksheetWriter calls the
nextBlock() method to load a row-block for writing.
When the row-block returns the flag EOF, mean is the current worksheet
finished written, and the next worksheet is written.
Extends the existing worksheet to implement a custom data source worksheet.
The data source can be micro-services, Mybatis, JPA or any others. If
the data source returns an array of json objects, please convert to
an object ArrayList or Map ArrayList, the object ArrayList needs to
extends ListSheet, the Map ArrayList needs to extends
ListMapSheet and implement the ListSheet.more() method.
If other formats cannot be converted to ArrayList, you
need to inherit from the base class Sheet and implement the
resetBlockData() and getHeaderColumns() methods.
ListSheet,
ListMapSheet,
ResultSetSheet,
StatementSheet,
CSVSheet| 限定符和类型 | 类和说明 |
|---|---|
static class |
Sheet.Column
Associated with Worksheet for controlling head style and cache
column data types and conversions
|
| 限定符和类型 | 字段和说明 |
|---|---|
protected int |
autoOdd
Automatic interlacing color
|
protected int |
autoSize
To mark the cell auto-width
|
protected ICellValueAndStyle |
cellValueAndStyle |
protected Sheet.Column[] |
columns |
protected Comments |
comments
The header column comments
|
protected int |
copyCount |
protected boolean |
copySheet
A copy worksheet flag
|
protected boolean |
headerReady
To mark the header column is ready
|
protected int |
headStyle |
protected boolean |
hidden
Mark the cell is hidden
|
protected int |
id |
protected org.slf4j.Logger |
LOGGER |
protected String |
name |
protected int |
oddFill
Odd row's background color
|
protected RelManager |
relManager |
protected RowBlock |
rowBlock |
protected int |
rows
The row number
|
protected IWorksheetWriter |
sheetWriter |
protected boolean |
shouldClose
Close resource on the last copy worksheet
|
protected WaterMark |
waterMark |
protected double |
width
The default cell width
|
protected Workbook |
workbook |
| 构造器和说明 |
|---|
Sheet() |
Sheet(String name)
Constructor worksheet
|
Sheet(String name,
Sheet.Column... columns)
Constructor worksheet
|
Sheet(String name,
WaterMark waterMark,
Sheet.Column... columns)
Constructor worksheet
|
| 限定符和类型 | 方法和说明 |
|---|---|
Sheet |
addRel(Relationship rel)
Add relationship
|
void |
afterSheetAccess(Path workSheetPath)
Write some final info
|
Sheet |
autoSize()
Setting auto resize cell's width
|
Sheet |
cancelOddStyle()
Cancel the odd row's fill style
|
void |
checkColumnLimit()
Check the limit of columns
|
Sheet |
clone() |
void |
close()
abstract method close
|
Comments |
createComments()
Create a
Comments and add relationship |
int |
defaultHeadStyle() |
Relationship |
findRel(String key) |
Sheet |
fixSize()
Setting fix column width
|
Sheet |
fixSize(double width)
Setting fix column width
|
int |
getAutoOdd() |
int |
getAutoSize()
Returns the re-size setting
|
Comments |
getComments()
Returns the header column
Comments |
protected String |
getCopySheetName()
Returns the copy worksheet name
|
double |
getDefaultWidth()
Return the cell default width
|
String |
getFileName()
Returns the worksheet name
|
Sheet.Column[] |
getHeaderColumns()
Returns the header column info
The copy sheet will use the parent worksheet header information.
|
int |
getId() |
String |
getName()
Returns the worksheet name
|
int |
getOddFill()
Returns the odd columns fill style
|
int |
getRowBlockSize()
The worksheet is written by units of row-block.
|
SharedStrings |
getSst()
Returns shared string
|
WaterMark |
getWaterMark()
Returns the
WaterMark |
Workbook |
getWorkbook()
Returns workbook
|
boolean |
hasHeaderColumns()
Check the header information is exist
|
boolean |
hasNonHeader()
Check empty header row
|
Sheet |
hidden()
Setting the worksheet status
|
static char[] |
int2Col(int n)
Int conversion to column string number.
|
boolean |
isAutoSize()
Test is auto size column width
|
boolean |
isHidden()
Returns the worksheet is hidden
|
RowBlock |
nextBlock()
Returns a row-block.
|
protected static boolean |
nonOrIntDefault(int style) |
protected void |
paging()
Split worksheet data
|
protected abstract void |
resetBlockData()
Each row-block is multiplexed and will be called to reset
the data when a row-block is completely written.
|
void |
setAutoOdd(int autoOdd) |
void |
setCellValueAndStyle(ICellValueAndStyle cellValueAndStyle) |
Sheet |
setColumns(Sheet.Column[] columns)
Setting the header rows's columns
|
Sheet |
setHeadStyle(Font font,
Fill fill,
Border border)
Setting the header column styles
|
Sheet |
setHeadStyle(Font font,
Fill fill,
Border border,
int vertical,
int horizontal)
Setting the header column styles
|
Sheet |
setHeadStyle(int style)
Setting the header cell styles
|
Sheet |
setHeadStyle(NumFmt numFmt,
Font font,
Fill fill,
Border border,
int vertical,
int horizontal)
Setting the header column styles
|
void |
setId(int id) |
Sheet |
setName(String name)
Setting the worksheet name
|
Sheet |
setOddFill(Fill fill)
Setting the odd row's fill style
|
void |
setSheetWriter(IWorksheetWriter sheetWriter) |
Sheet |
setWaterMark(WaterMark waterMark)
Setting the
WaterMark |
Sheet |
setWorkbook(Workbook workbook)
Setting the workbook
|
int |
size()
Returns total rows in this worksheet
|
void |
what(String code)
Output the export detail info
|
void |
what(String code,
String... args)
Output export detail info
|
void |
writeTo(Path path)
Write worksheet data to path
|
protected final org.slf4j.Logger LOGGER
protected Workbook workbook
protected String name
protected Sheet.Column[] columns
protected WaterMark waterMark
protected RelManager relManager
protected int id
protected Comments comments
protected int autoSize
protected double width
protected int rows
protected boolean hidden
protected int headStyle
protected int autoOdd
protected int oddFill
protected boolean copySheet
protected int copyCount
protected RowBlock rowBlock
protected IWorksheetWriter sheetWriter
protected boolean headerReady
protected boolean shouldClose
protected ICellValueAndStyle cellValueAndStyle
public Sheet()
public Sheet(String name)
name - the worksheet namepublic Sheet(String name, Sheet.Column... columns)
name - the worksheet namecolumns - the header infopublic Sheet(String name, WaterMark waterMark, Sheet.Column... columns)
name - the worksheet namewaterMark - the water markcolumns - the header infopublic int getId()
public void setId(int id)
public void setSheetWriter(IWorksheetWriter sheetWriter)
public void setCellValueAndStyle(ICellValueAndStyle cellValueAndStyle)
public void what(String code)
code - the message code in message properties filepublic void what(String code, String... args)
code - the message code in message properties fileargs - the placeholder valuespublic SharedStrings getSst()
SharedStringspublic double getDefaultWidth()
public Sheet fixSize(double width)
width - the column widthSheetpublic int getAutoSize()
public boolean isAutoSize()
public int getAutoOdd()
public void setAutoOdd(int autoOdd)
public Sheet setOddFill(Fill fill)
fill - the fill styleSheetpublic int getOddFill()
public String getName()
public Sheet setName(String name)
name - the worksheet nameSheetpublic Comments getComments()
Commentspublic Comments createComments()
Comments and add relationshippublic Sheet.Column[] getHeaderColumns()
The copy sheet will use the parent worksheet header information.
public Sheet setColumns(Sheet.Column[] columns)
columns - the header row's columnsSheetpublic boolean isHidden()
public void close()
throws IOException
IOException - if I/O error occurpublic void writeTo(Path path) throws IOException
writeTo 在接口中 Storablepath - the storage pathIOException - if I/O error occurprotected void paging()
public Sheet addRel(Relationship rel)
rel - Relationshippublic Relationship findRel(String key)
public String getFileName()
public Sheet setHeadStyle(Font font, Fill fill, Border border)
font - the fontfill - the fill styleborder - the border styleSheetpublic Sheet setHeadStyle(Font font, Fill fill, Border border, int vertical, int horizontal)
font - the fontfill - the fill styleborder - the border stylevertical - the vertical stylehorizontal - the horizontal styleSheetpublic Sheet setHeadStyle(NumFmt numFmt, Font font, Fill fill, Border border, int vertical, int horizontal)
numFmt - the number formatfont - the fontfill - the fill styleborder - the border stylevertical - the vertical stylehorizontal - the horizontal styleSheetpublic Sheet setHeadStyle(int style)
style - the styles valueSheetpublic int defaultHeadStyle()
protected static boolean nonOrIntDefault(int style)
public int size()
public RowBlock nextBlock()
public int getRowBlockSize()
more()
method will be called to get more data.public void afterSheetAccess(Path workSheetPath) throws IOException
workSheetPath - the worksheet pathIOException - if I/O error occurprotected String getCopySheetName()
public void checkColumnLimit()
public boolean hasHeaderColumns()
public static char[] int2Col(int n)
int | column number -------|--------- 1 | A 10 | J 26 | Z 27 | AA 28 | AB 53 | BA 16_384 | XFD
n - the column numberpublic boolean hasNonHeader()
protected abstract void resetBlockData()
getRowBlockSize() method to get
the row-block size, call the ICellValueAndStyle.reset(int, Cell, Object, Sheet.Column)
method to set value and styles.Copyright © 2020. All rights reserved.