@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
已过时。
use the new
Column |
| 限定符和类型 | 字段和说明 |
|---|---|
protected int |
autoOdd
Automatic interlacing color
|
protected int |
autoSize
To mark the cell auto-width
|
protected ICellValueAndStyle |
cellValueAndStyle |
protected Column[] |
columns |
protected Comments |
comments
The header column comments
|
protected int |
copyCount |
protected boolean |
copySheet
A copy worksheet flag
|
protected Map<String,Object> |
extProp
Other extend properties
|
protected int |
extPropMark
The bit flag of the extended parameter.
|
protected int |
forceExport
Force export all attributes
|
protected boolean |
headerReady
To mark the header column is ready
|
protected int |
headStyle
The header style value
|
protected int |
headStyleIndex
The header style index
|
protected boolean |
hidden
Mark the cell is hidden
|
protected int |
id |
protected org.slf4j.Logger |
LOGGER |
protected String |
name |
protected int |
nonHeader
Ignore header when export
|
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,
Column... columns)
Constructor worksheet
|
Sheet(String name,
WaterMark waterMark,
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
|
int |
buildHeadStyle(String fontColor,
String fillBgColor)
Custom header style according to parameters
|
Sheet |
cancelForceExport()
Cancel force export
|
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()
Build default header style
|
int |
defaultHeadStyleIndex()
Build default header style
|
Relationship |
findRel(String key) |
Sheet |
fixSize()
Setting fix column width
|
Sheet |
fixSize(double width)
Setting fix column width
|
Sheet |
forceExport()
Force export of attributes without
ExcelColumn annotations |
Column[] |
getAndSortHeaderColumns()
Sort column by
colIndex |
int |
getAutoOdd()
Returns auto setting odd background flag
|
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
|
Map<String,Object> |
getExtPropAsMap()
Shallow copy all extend properties
|
Object |
getExtPropValue(String key)
Returns the value to which the specified key in extend property,
or
null if it contains no mapping for the key. |
String |
getFileName()
Returns the worksheet name
|
int |
getForceExport()
Returns the force export
|
protected Column[] |
getHeaderColumns()
Returns the header column info
The copy sheet will use the parent worksheet header information.
|
int |
getHeadStyle()
Returns the header style value
|
int |
getHeadStyleIndex()
Returns the header style index
|
int |
getId() |
String |
getName()
Returns the worksheet name
|
int |
getNonHeader()
Returns the nonHeader value.
|
int |
getOddFill()
Returns the odd columns fill style
|
int |
getRowBlockSize()
The worksheet is written by units of row-block.
|
protected int |
getRowLimit()
The Worksheet row limit
|
SharedStrings |
getSst()
Returns shared string
|
WaterMark |
getWaterMark()
Returns the
WaterMark |
Workbook |
getWorkbook()
Returns workbook
|
boolean |
hasHeaderColumns()
Check the header information is exist
|
Sheet |
hidden()
Setting the worksheet status
|
Sheet |
ignoreHeader()
Settings nonHeader property
|
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
|
protected void |
markExtProp()
Mark ext-properties bit
|
RowBlock |
nextBlock()
Returns a row-block.
|
protected static boolean |
nonOrIntDefault(int style) |
protected void |
paging()
Split worksheet data
|
Sheet |
putAllExtProp(Map<String,Object> m)
Copies all of the mappings from the specified map to extend properties
|
Sheet |
putExtProp(String key,
Object value)
Append extend property
|
Sheet |
putExtPropIfAbsent(String key,
Object value)
If the specified key is not already associated with a value (or is mapped
to
null) associates it with the given value and returns
null, else returns the current value. |
protected abstract void |
resetBlockData()
Each row-block is multiplexed and will be called to reset
the data when a row-block is completely written.
|
protected void |
resetCommonProperties(Column[] columns) |
protected int |
search(Column[] columns,
int n,
int k) |
Sheet |
setAutoOdd(int autoOdd)
Setting auto setting odd background flag
|
void |
setCellValueAndStyle(ICellValueAndStyle cellValueAndStyle) |
Sheet |
setColumns(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
|
Sheet |
setHeadStyleIndex(int styleIndex)
Setting the header cell 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
|
protected void |
sortColumns(Column[] columns) |
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 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 headStyleIndex
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
protected int forceExport
protected int nonHeader
protected int extPropMark
public Sheet()
public Sheet(String name)
name - the worksheet namepublic Sheet(String name, Column... columns)
name - the worksheet namecolumns - 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()
SharedStrings in workbookpublic double getDefaultWidth()
public Sheet fixSize(double width)
width - the column widthSheetpublic int getAutoSize()
public boolean isAutoSize()
public int getAutoOdd()
public Sheet setAutoOdd(int autoOdd)
autoOdd - 1: setting, others noneSheetpublic 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 relationshipprotected Column[] getHeaderColumns()
The copy sheet will use the parent worksheet header information.
Use the method getAndSortHeaderColumns() to get Columns
public Column[] getAndSortHeaderColumns()
colIndexprotected void resetCommonProperties(Column[] columns)
protected void sortColumns(Column[] columns)
protected int search(Column[] columns, int n, int k)
public Sheet setColumns(Column[] columns)
columns - the header row's columnsSheetpublic boolean isHidden()
public Sheet forceExport()
ExcelColumn annotationsSheetpublic int getForceExport()
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 Sheet setHeadStyleIndex(int styleIndex)
styleIndex - the styles indexSheetpublic int getHeadStyle()
public int getHeadStyleIndex()
public int buildHeadStyle(String fontColor, String fillBgColor)
fontColor - the font colorfillBgColor - the fill background colorpublic int defaultHeadStyle()
public int defaultHeadStyleIndex()
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)
16_384 after office 2007 and 256 in office 2003
int | column number -------|--------- 1 | A 10 | J 26 | Z 27 | AA 28 | AB 53 | BA 16_384 | XFD
n - the column numberpublic Sheet ignoreHeader()
public int getNonHeader()
protected int getRowLimit()
public Sheet putExtProp(String key, Object value)
key - key with which the specified value is to be associatedvalue - value to be associated with the specified keypublic Sheet putExtPropIfAbsent(String key, Object value)
null) associates it with the given value and returns
null, else returns the current value.key - key with which the specified value is to be associatedvalue - value to be associated with the specified keypublic Sheet putAllExtProp(Map<String,Object> m)
m - mappings to be stored in this mappublic Object getExtPropValue(String key)
null if it contains no mapping for the key.key - the key whose associated value is to be returnedpublic Map<String,Object> getExtPropAsMap()
protected void markExtProp()
protected abstract void resetBlockData()
getRowBlockSize() method to get
the row-block size, call the ICellValueAndStyle.reset(int, Cell, Object, org.ttzero.excel.entity.Column)
method to set value and styles.Copyright © 2022. All rights reserved.