public class Worksheet extends Object
| Modifier and Type | Field and Description |
|---|---|
static int |
MAX_COL_WIDTH
Maximum column width in Excel.
|
static int |
MAX_COLS
Maximum number of columns in Excel.
|
static int |
MAX_ROWS
Maximum number of rows in Excel.
|
| Modifier and Type | Method and Description |
|---|---|
void |
finish()
Finish the construction of this worksheet.
|
void |
flush()
Write all the rows currently in memory to the workbook's output stream.
|
void |
formula(int r,
int c,
String expression)
Set the cell formula at the given coordinates.
|
String |
getName()
Get worksheet name.
|
VisibilityState |
getVisibilityState() |
Workbook |
getWorkbook()
Get parent workbook.
|
void |
hideColumn(int column)
Hide the given column.
|
void |
hideRow(int row)
Hide the given row.
|
void |
protect(String password)
Protects the sheet with a password.
|
void |
protect(String password,
Set<SheetProtectionOption> options)
Protects the sheet with a password.
|
void |
protect(String password,
SheetProtectionOption... options)
Protects the sheet with a password.
|
Range |
range(int top,
int left,
int bottom,
int right)
Create a new range of cells.
|
void |
setVisibilityState(VisibilityState visibilityState)
Sets the visibility state of the sheet
|
void |
showColumn(int column)
Show the given column.
|
void |
showRow(int row)
Show the given row.
|
StyleSetter |
style(int r,
int c)
Get a new style setter for a cell.
|
Object |
value(int r,
int c)
Get the cell value (or formula) at the given coordinates.
|
void |
value(int r,
int c,
Object value)
Set the cell value at the given coordinates.
|
void |
width(int c,
double width)
Specify the width for the given column.
|
public static final int MAX_ROWS
public static final int MAX_COLS
public static final int MAX_COL_WIDTH
public String getName()
public Workbook getWorkbook()
public void setVisibilityState(VisibilityState visibilityState)
This is done by setting the state attribute in the workbook.xml.
public VisibilityState getVisibilityState()
public void hideRow(int row)
row - Zero-based row numberpublic void showRow(int row)
row - Zero-based row numberpublic void hideColumn(int column)
column - Zero-based column numberpublic void showColumn(int column)
column - Zero-based column numberpublic void protect(String password)
SheetProtectionOptions and
'sheet'. (Note that this is not very secure and only meant for discouraging changes.)password - The password to use.public void protect(String password, SheetProtectionOption... options)
password - The password to use.options - An array of all the SheetProtectionOptions to protect.public void protect(String password, Set<SheetProtectionOption> options)
password - The password to use.options - A Set of all the SheetProtectionOptions to protect.public void width(int c,
double width)
The maximum column width in excel is 255. The colum width in excel is the number of characters that can be displayed with the standard font (first font in the workbook).
Note: The xml spec specifies additional padding for each cell (Section 3.3.1.12 of the OOXML spec) which will result in slightly less characters being displayed then what is given here.
c - Zero-based column numberwidth - The width of the column in character widthspublic void value(int r,
int c,
Object value)
r - Zero-based row number.c - Zero-based column number.value - Cell value. Supported types are
String, Date, LocalDate, LocalDateTime, ZonedDateTime,
Number and Boolean implementations. Note Excel timestamps do not carry
any timezone information; Date values are converted to an Excel
serial number with the system timezone. If you need a specific timezone,
prefer passing a ZonedDateTime.public Object value(int r, int c)
r - Zero-based row number.c - Zero-based column number.Formula).public void formula(int r,
int c,
String expression)
r - Zero-based row number.c - Zero-based column number.expression - Cell formula expression.public StyleSetter style(int r, int c)
r - Zero-based row number.c - Zero-based column number.public Range range(int top, int left, int bottom, int right)
top <= bottom and left <=
right.top - Top row.left - Left column.bottom - Bottom row.right - Right column.public void finish()
throws IOException
IOException - If an I/O error occurs.public void flush()
throws IOException
flush(), all the rows created so far become inaccessible.IOException - If an I/O error occurs.Copyright © 2019. All rights reserved.