@TopNS(prefix={"","r"}, value="worksheet", uri={"http://schemas.openxmlformats.org/spreadsheetml/2006/main","http://schemas.openxmlformats.org/officeDocument/2006/relationships"}) public class XMLWorksheetWriter extends Object implements IWorksheetWriter
| 限定符和类型 | 字段和说明 |
|---|---|
protected ExtBufferedWriter |
bw |
protected static char[] |
cacheChar
Char buffer
|
protected Column[] |
columns |
protected Comments |
comments |
protected IDrawingsWriter |
drawingsWriter
Picture and Chart Support
|
protected boolean |
includeAutoWidth
If there are any auto-width columns
|
protected org.slf4j.Logger |
LOGGER
LOGGER
|
protected Path |
mediaPath |
protected Sheet |
sheet |
protected int |
sheetDataReady |
protected SharedStrings |
sst |
protected int |
startHeaderRow |
protected int |
startRow |
protected int |
totalRows |
protected Path |
workSheetPath |
| 构造器和说明 |
|---|
XMLWorksheetWriter() |
XMLWorksheetWriter(Sheet sheet) |
| 限定符和类型 | 方法和说明 |
|---|---|
protected void |
afterSheetData()
Append others customize info
|
protected void |
beforeSheetData(boolean nonHeader)
Begin to write the Sheet data and the header row.
|
IWorksheetWriter |
clone()
Clone
|
void |
close()
Release resources
|
IDrawingsWriter |
createDrawingsWriter()
Create drawing writer and add relationship
|
protected Picture |
createPicture(int column,
int row)
Picture constructor
You can use this method to add general effects
|
void |
downloadCompleted(Picture picture,
byte[] body)
Complete downloading, check the file signatures and set the subscript
Picture.idx to idle |
void |
downloadRemoteResource(Picture picture,
String url)
Download remote resources
By default, only HTTP or HTTPS protocols are supported.
|
int |
getColumnLimit()
The Worksheet column limit
|
double |
getHeaderHeight(Column[][] columnsArray,
int row)
Returns the maximum cell height
|
int |
getRowLimit()
Override this method to modify the maximum number
of rows per page, this value contains the header
row and data rows
eq: limit is 100 means data has 99 rows
|
protected boolean |
hasMedia()
Check if images are output
|
protected void |
initDrawingsWriter()
Initialization DrawingsWriter
|
protected Path |
initWriter(Path root) |
static boolean |
isFirstMergedCell(List<Dimension> mergeCells,
int row,
int col)
Test whether the coordinate is the first cell of the merged cell,
and use
Grid.test(int, int) to determine yes before calling this method |
protected void |
resizeColumnWidth(File path,
int rows)
Resize column width
|
IWorksheetWriter |
setWorksheet(Sheet sheet)
Rest worksheet
|
protected int |
startRow(int rows,
int columns)
已过时。
replace with
startRow(int, int, double) |
protected int |
startRow(int rows,
int columns,
double rowHeight)
Write begin of row
|
protected double |
stringWidth(String s,
int xf)
Calculate text width
FIXME reference
SwingUtilities2.stringWidth(javax.swing.JComponent, java.awt.FontMetrics, java.lang.String) |
protected void |
writeAfter(int total)
Write at after worksheet body
|
protected void |
writeBefore()
Write worksheet header data
|
protected void |
writeBinary(byte[] bytes,
int row,
int column,
int xf)
Write binary file
|
protected void |
writeBinary(ByteBuffer byteBuffer,
int row,
int column,
int xf)
Write binary file
|
protected void |
writeBool(boolean bool,
int row,
int column,
int xf)
Write boolean value
|
protected void |
writeChar(char c,
int row,
int column,
int xf)
Write char value
|
protected void |
writeCols(int fillSpace,
String defaultWidth)
Write the default column info, The specified column width will be overwritten in these method.
|
protected void |
writeDecimal(BigDecimal bd,
int row,
int column,
int xf)
Write decimal value
|
protected void |
writeDecimalAutoSize(BigDecimal bd,
int row,
int column,
int xf)
已过时。
|
protected void |
writeDimension()
Write the dimension of sheet, default value is
A1 |
protected void |
writeDouble(double d,
int row,
int column,
int xf)
Write double value
|
protected void |
writeDoubleAutoSize(double d,
int row,
int column,
int xf)
已过时。
|
protected void |
writeFile(Path path,
int row,
int column,
int xf)
Write file value
|
protected int |
writeHeaderRow()
Write the header row
|
protected void |
writeMergeCells()
Append merged cells if exists
|
protected void |
writeNull(int row,
int column,
int xf)
Write blank value
|
protected void |
writeNumeric(long l,
int row,
int column,
int xf)
Write numeric value
|
protected void |
writeNumericAutoSize(long l,
int row,
int column,
int xf)
已过时。
|
protected void |
writePictureDirect(int id,
String name,
int column,
int row,
FileSignatures.Signature signature) |
protected void |
writeRemoteMedia(String url,
int row,
int column,
int xf)
Write remote media value
|
protected void |
writeRootNode()
Write the <worksheet> node
|
protected void |
writeRow(Row row)
Write a row data
|
protected void |
writeRowAutoSize(Row row)
已过时。
|
protected void |
writeRowBlock(RowBlock rowBlock)
Write a row-block
|
protected void |
writeSheetFormat(int fillSpace,
String defaultWidth)
Write the sheet format
|
protected void |
writeSheetViews()
Write the sheet views such as FreezeEnum, Default selection cell.
|
protected void |
writeStream(InputStream stream,
int row,
int column,
int xf)
Write stream value
|
protected void |
writeString(String s,
int row,
int column,
int xf)
Write string value
|
protected void |
writeStringAutoSize(String s,
int row,
int column,
int xf)
已过时。
|
void |
writeTo(Path path)
Write a row block
|
void |
writeTo(Path path,
Supplier<RowBlock> supplier)
Write a row block
|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitisBigDecimal, isBool, isChar, isDate, isDateTime, isDouble, isFloat, isInt, isLocalDate, isLocalDateTime, isLocalTime, isLong, isOutOfSheet, isShort, isString, isTime, writeEmptySheetprotected final org.slf4j.Logger LOGGER
protected Path workSheetPath
protected Path mediaPath
protected ExtBufferedWriter bw
protected Sheet sheet
protected Column[] columns
protected SharedStrings sst
protected Comments comments
protected int startRow
protected int startHeaderRow
protected int totalRows
protected int sheetDataReady
protected boolean includeAutoWidth
protected IDrawingsWriter drawingsWriter
protected static char[] cacheChar
public XMLWorksheetWriter()
public XMLWorksheetWriter(Sheet sheet)
public void writeTo(Path path, Supplier<RowBlock> supplier) throws IOException
writeTo 在接口中 IWorksheetWritersupplier - a row-block supplierpath - the storage pathIOException - if I/O error occurpublic void writeTo(Path path) throws IOException
writeTo 在接口中 Storablepath - the storage pathIOException - if I/O error occurprotected Path initWriter(Path root) throws IOException
IOExceptionpublic IWorksheetWriter setWorksheet(Sheet sheet)
setWorksheet 在接口中 IWorksheetWritersheet - the worksheetpublic IWorksheetWriter clone()
IWorksheetWriterclone 在接口中 IWorksheetWriterclone 在类中 Objectpublic int getRowLimit()
eq: limit is 100 means data has 99 rows
getRowLimit 在接口中 IWorksheetWriterpublic int getColumnLimit()
getColumnLimit 在接口中 IWorksheetWriterprotected void writeBefore()
throws IOException
IOException - if I/O error occurprotected int writeHeaderRow()
throws IOException
IOException - if I/O error occurprotected void writeAfter(int total)
throws IOException
total - the total of rowsIOException - if I/O error occurprotected void writeRowBlock(RowBlock rowBlock) throws IOException
rowBlock - the row-blockIOException - if I/O error occur.@Deprecated protected int startRow(int rows, int columns) throws IOException
startRow(int, int, double)rows - the row index (zero base)columns - the column lengthIOException - if I/O error occurprotected int startRow(int rows,
int columns,
double rowHeight)
throws IOException
rows - the row index (zero base)columns - the column lengthrowHeight - the row heightIOException - if I/O error occurprotected void writeRow(Row row) throws IOException
row - a row dataIOException - if I/O error occur@Deprecated protected void writeRowAutoSize(Row row) throws IOException
row - a row dataIOException - if I/O error occurprotected void writeString(String s, int row, int column, int xf) throws IOException
s - the string valuerow - the row indexcolumn - the column indexxf - the style indexIOException - if I/O error occur@Deprecated protected void writeStringAutoSize(String s, int row, int column, int xf) throws IOException
s - the string valuerow - the row indexcolumn - the column indexxf - the style indexIOException - if I/O error occurprotected void writeDouble(double d,
int row,
int column,
int xf)
throws IOException
d - the double valuerow - the row indexcolumn - the column indexxf - the style indexIOException - if I/O error occur@Deprecated protected void writeDoubleAutoSize(double d, int row, int column, int xf) throws IOException
d - the double valuerow - the row indexcolumn - the column indexxf - the style indexIOException - if I/O error occurprotected void writeDecimal(BigDecimal bd, int row, int column, int xf) throws IOException
bd - the decimal valuerow - the row indexcolumn - the column indexxf - the style indexIOException - if I/O error occur@Deprecated protected void writeDecimalAutoSize(BigDecimal bd, int row, int column, int xf) throws IOException
bd - the decimal valuerow - the row indexcolumn - the column indexxf - the style indexIOException - if I/O error occurprotected void writeChar(char c,
int row,
int column,
int xf)
throws IOException
c - the character valuerow - the row indexcolumn - the column indexxf - the style indexIOException - if I/O error occurprotected void writeNumeric(long l,
int row,
int column,
int xf)
throws IOException
l - the numeric valuerow - the row indexcolumn - the column indexxf - the style indexIOException - if I/O error occur@Deprecated protected void writeNumericAutoSize(long l, int row, int column, int xf) throws IOException
l - the numeric valuerow - the row indexcolumn - the column indexxf - the style indexIOException - if I/O error occurprotected void writeBool(boolean bool,
int row,
int column,
int xf)
throws IOException
bool - the boolean valuerow - the row indexcolumn - the column indexxf - the style indexIOException - if I/O error occurprotected void writeNull(int row,
int column,
int xf)
throws IOException
row - the row indexcolumn - the column indexxf - the style indexIOException - if I/O error occurprotected void writeBinary(byte[] bytes,
int row,
int column,
int xf)
throws IOException
bytes - the binary datarow - the row indexcolumn - the column indexxf - the style indexIOException - if I/O error occurprotected void writeBinary(ByteBuffer byteBuffer, int row, int column, int xf) throws IOException
byteBuffer - the binary datarow - the row indexcolumn - the column indexxf - the style indexIOException - if I/O error occurprotected void writeFile(Path path, int row, int column, int xf) throws IOException
path - the picture filerow - the row indexcolumn - the column indexxf - the style indexIOException - if I/O error occurprotected void writeStream(InputStream stream, int row, int column, int xf) throws IOException
stream - the picture input-streamrow - the row indexcolumn - the column indexxf - the style indexIOException - if I/O error occurprotected void writeRemoteMedia(String url, int row, int column, int xf) throws IOException
url - remote urlrow - the row indexcolumn - the column indexxf - the style indexIOException - if I/O error occurprotected void resizeColumnWidth(File path, int rows) throws IOException
path - the sheet temp pathrows - total of rowsIOException - if I/O error occurpublic void close()
close 在接口中 Closeableclose 在接口中 AutoCloseableprotected void writeRootNode()
throws IOException
IOException - if I/O error occur.protected void writeDimension()
throws IOException
A1IOException - if I/O error occur.protected void writeSheetViews()
throws IOException
IOException - if I/O error occur.protected void writeSheetFormat(int fillSpace,
String defaultWidth)
throws IOException
fillSpace - The number of characters to pad when recalculating the width.defaultWidth - The default cell width, 8.38 will be use if it not be setting.IOException - if I/O error occur.protected void writeCols(int fillSpace,
String defaultWidth)
throws IOException
fillSpace - The number of characters to pad when recalculating the width.defaultWidth - The default cell width, 8.38 will be use if it not be setting.IOException - if I/O error occur.protected void beforeSheetData(boolean nonHeader)
throws IOException
nonHeader - mark none headerIOException - if I/O error occur.protected void afterSheetData()
throws IOException
IOException - if I/O error occur.protected void writeMergeCells()
throws IOException
IOException - if I/O error occur.protected double stringWidth(String s, int xf)
SwingUtilities2.stringWidth(javax.swing.JComponent, java.awt.FontMetrics, java.lang.String)s - the string valuexf - the style indexpublic static boolean isFirstMergedCell(List<Dimension> mergeCells, int row, int col)
Grid.test(int, int) to determine yes before calling this methodmergeCells - all merged cellsrow - the cell rowcol - the cell columnpublic double getHeaderHeight(Column[][] columnsArray, int row)
columnsArray - the header column arrayrow - actual rows in Excelprotected boolean hasMedia()
protected void initDrawingsWriter()
throws IOException
IOException - if I/O error occurpublic IDrawingsWriter createDrawingsWriter()
IDrawingsWriterpublic void downloadRemoteResource(Picture picture, String url) throws IOException
HttpURLConnection to synchronously download remote resources.
For more complex scenarios (asynchronous download, Connection pool, authentication, FTP, etc.), please override this methodpicture - Picture infourl - remote urlIOException - if I/O error occur.public void downloadCompleted(Picture picture, byte[] body) throws IOException
Picture.idx to idlepicture - Picture infobody - thr resource dataIOException - if I/O error occur.protected void writePictureDirect(int id,
String name,
int column,
int row,
FileSignatures.Signature signature)
throws IOException
IOExceptionCopyright © 2023. All rights reserved.