public class Sheet extends Object implements Cloneable, Comparable<Sheet>
Constructor and Description |
---|
Sheet(String name)
Create an empty sheet with a given name.
|
Sheet(String name,
int rows,
int columns)
Create an empty sheet with a given name and dimmensions
|
Modifier and Type | Method and Description |
---|---|
void |
appendColumn()
Append a column at the end of the Spreadsheet
|
void |
appendColumns(int howmany)
Append many columns at the end of the Spreadsheet.
|
void |
appendRow()
Append a new row at the end of the heet
|
void |
appendRows(int howmany)
Append many rows at the end of the Spreadsheet
|
void |
clear()
Clear all the content of the sheet.
|
Object |
clone() |
boolean |
columnIsHidden(int column)
Determinies if a specific column is hidden or not
|
int |
compareTo(Sheet o)
compareTo method, this comparator only compare the names
Note: this class has a natural ordering that is inconsistent with equals.
|
void |
deleteColumn(int column)
Delete a specific column on the sheet
|
void |
deleteColumns(int column,
int howmany)
Delete a number of columns starting in a specific index
|
void |
deleteRow(int row)
Delete a specific row in the sheet
|
void |
deleteRows(int row,
int howmany)
Delete a number of rows starting in a specific index
|
boolean |
equals(Object o)
Equals method, two sheets are considered the same if have the same name and the same content (include formatting)
|
Double |
getColumnWidth(int column)
Get the width of a column
|
Range |
getDataRange()
Get a @Range which contains the whole Sheet content.
|
Style |
getDefaultColumnCellStyle(int column)
Gets the default cell style of a specific column.
|
int |
getLastColumn()
Deprecated.
Use getMaxColumn() instead
Return the last column of the sheet which contains useful data
|
int |
getLastRow()
Deprecated.
Use getMaxRow() instead
Return the last row of the sheet which contains useful data
|
int |
getMaxColumns()
The number of columns created in this sheet
|
int |
getMaxRows()
The number of rows created in this sheet
|
String |
getName()
Obtains the name of this sheet
|
Range |
getRange(int row,
int column)
Obtains a @Range which contains a specific cell of the sheet
|
Range |
getRange(int row,
int column,
int numRows)
Obtains a @Range which represents a number of rows starting
in a specific Cell.
|
Range |
getRange(int row,
int column,
int numRows,
int numColumns)
Obtains a @Range which represents a subset of the Sheet.
|
Range |
getRange(String a1Notation)
Obtains a @Range using the A1 Notation format.
|
Double |
getRowHeight(int row)
Get the height of a row
|
int |
hashCode() |
void |
hideColumn(int column)
Hides a column specified by his index
|
void |
hideColumns(int column,
int howmany)
Hides a column specified by a range
|
void |
hideRow(int row)
Hides a row specified by his index
|
void |
hideRows(int row,
int howmany)
Hides a row specified by a range
|
void |
hideSheet()
Mark this sheet as hidden
|
void |
insertColumnAfter(int afterPosition)
Insert a column after a specific position
|
void |
insertColumnBefore(int beforePosition)
Insert a column before a specific position
|
void |
insertColumnsAfter(int columnIndex,
int howmany)
Insert a number of columns after a specific position
|
void |
insertColumnsBefore(int columnIndex,
int howmany)
Insert a number of columns before a specific position
|
void |
insertRowAfter(int afterPosition)
Insert a row after a specific position
|
void |
insertRowBefore(int beforePosition)
Insert a row before a specific position
|
void |
insertRowsAfter(int rowIndex,
int howmany)
Insert a row after a specific position
|
void |
insertRowsBefore(int rowIndex,
int howmany)
Insert a row before a specific position
|
boolean |
isHidden()
Determinies if the sheet is marked as hidden or not
|
boolean |
isProtected()
Determines if this sheet is protected by a password or not
|
boolean |
rowIsHidden(int row)
Determinies if a specific row is hidden or not
|
void |
setColumnWidth(int column,
Double width)
Set a specific column width to a specific column
|
void |
setColumnWidths(int column,
int numColumns,
Double width)
Set a column width to a specific set of columns
|
void |
setDefaultColumnCellStyle(int column,
Style defaultColumnCellStyle)
Sets the default cell style of a specific column.
|
void |
setName(String newName)
Rename this sheet
|
void |
setPassword(String key)
Sets a password for a sheet.
|
void |
setRowHeight(int row,
Double height)
Set a specific row height to a specific row
|
void |
setRowHeights(int row,
int numRows,
Double height)
Set a row height to a specific set of rows
|
void |
showColumn(int column)
Unhides the columns at the given index.
|
void |
showRow(int row)
Unhides the row at the given index.
|
void |
showSheet()
Mark this sheet as visible
|
String |
toString() |
void |
trim()
Deprecated.
This function should not be called since it won't make any visible difference to the user. This is going to be moved to private visibility
|
public Sheet(String name)
name
- A name which identifies this sheetpublic Sheet(String name, int rows, int columns)
name
- A name which identifies this sheetrows
- Number of rows in the sheetcolumns
- Number of columns in the sheetIllegalArgumentException
- If the number of rows/columns are negativeNullPointerException
- If the number of rows/columns are negativepublic void appendRow()
appendRows
public void appendRows(int howmany)
howmany
- The number of rows to be appendedIllegalArgumentException
- if howmany is negative, no changes will be done to the sheetpublic void appendColumn()
appendColumns
public void appendColumns(int howmany)
howmany
- The number of columns to be appendedIllegalArgumentException
- if howmany is negative, no changes will be done to the sheetpublic void clear()
public Object clone() throws CloneNotSupportedException
clone
in class Object
CloneNotSupportedException
public void deleteColumn(int column)
column
- The column index to be deletedIndexOutOfBoundsException
- if the index is invaliddeleteColumns
public void deleteColumns(int column, int howmany)
column
- The column index to starthowmany
- The number of columns to be deletedIndexOutOfBoundsException
- If columns + howmany is out bounds of the sheet. No changes will be done to the sheetIllegalArgumentException
- if howmany is negative, no changes will be done to the sheetpublic void deleteRow(int row)
row
- The row index to be deletedIndexOutOfBoundsException
- if the index is out of boundsdeleteRows
public void deleteRows(int row, int howmany)
row
- The row index where starthowmany
- How many rows will be deletedIndexOutOfBoundsException
- if row + howmany is out of bounds, no changes will be done to the sheetdeleteRows
public Double getColumnWidth(int column)
column
- The column index where startIndexOutOfBoundsException
- if the column index is invalidpublic Double getRowHeight(int row)
row
- The row index where startpublic Range getDataRange()
public int getMaxColumns()
public int getMaxRows()
public String getName()
public Range getRange(int row, int column)
row
- X Coordinate of the cellcolumn
- Y Coordinate of the cellIndexOutOfBoundsException
- if it represents a invalid rangepublic Range getRange(int row, int column, int numRows)
row
- X Coordinate of the starting cellcolumn
- Y Coordinate of the starting cellnumRows
- How many rows to takeIndexOutOfBoundsException
- if it represents a invalid rangegetRange(int, int, int, int)
public Range getRange(int row, int column, int numRows, int numColumns)
row
- X Coordinate of the starting cellcolumn
- Y Coordinate of the starting cellnumRows
- How many rows to takenumColumns
- How many columns to takeIndexOutOfBoundsException
- if it represents a invalid rangepublic Range getRange(String a1Notation)
a1Notation
- The string representation of the range in A1NotationNullPointerException
- If the argument is nullIllegalArgumentException
- If the argument is not a valid A1NotationIndexOutOfBoundsException
- If it represents a invalid rangepublic void hideRow(int row)
row
- The index of the rowIndexOutOfBoundsException
- if the index is invalidpublic void hideRows(int row, int howmany)
row
- The index of the rowhowmany
- The number of different rows to hideIndexOutOfBoundsException
- if the index is invalidpublic void hideColumn(int column)
column
- The index of the rowIndexOutOfBoundsException
- if the index is invalidpublic void hideColumns(int column, int howmany)
column
- The index of the rowhowmany
- The number of columnsIndexOutOfBoundsException
- if the index is invalidpublic void insertColumnAfter(int afterPosition)
afterPosition
- The index where insertIndexOutOfBoundsException
- if the index is invalidpublic void insertColumnBefore(int beforePosition)
beforePosition
- The index where insertIndexOutOfBoundsException
- if the index is invalidpublic void insertColumnsAfter(int columnIndex, int howmany)
columnIndex
- The index where inserthowmany
- How many columns to insertIndexOutOfBoundsException
- if the columnIndex is out of bounds, no changes will be doneIllegalArgumentException
- if howmany is negative, no changes will be donepublic void insertColumnsBefore(int columnIndex, int howmany)
columnIndex
- The index where inserthowmany
- How many columns to insertIndexOutOfBoundsException
- if the columnIndex is out of bounds, no changes will be doneIllegalArgumentException
- if howmany is negative, no changes will be donepublic void insertRowAfter(int afterPosition)
afterPosition
- The index where insertIndexOutOfBoundsException
- if the index is invalidpublic void insertRowBefore(int beforePosition)
beforePosition
- The index where insertIndexOutOfBoundsException
- if the index is invalidpublic void insertRowsBefore(int rowIndex, int howmany)
rowIndex
- The index where inserthowmany
- How many rows to insertIndexOutOfBoundsException
- if the index is out bounds, no changes will be done to the sheetIllegalArgumentException
- if howmany is negative, no changes will be done to the sheetpublic void insertRowsAfter(int rowIndex, int howmany)
rowIndex
- The index where inserthowmany
- How many rows to insertIndexOutOfBoundsException
- if the index is out bounds, no changes will be done to sheetIllegalArgumentException
- if howmany is negative, no changes will be done to the sheetpublic void setColumnWidth(int column, Double width)
column
- The index of the columnwidth
- The width of the column. It can be a null if you want to "unset" the widthIndexOutOfBoundsException
- if the column is negative or >= numColumnsIllegalArgumentException
- Width has to be positivepublic void setColumnWidths(int column, int numColumns, Double width)
column
- The index of the columnnumColumns
- The number of columns to be modified, starting on index.width
- The width of the column. It can be a null if you want to "unset" the widthIndexOutOfBoundsException
- if the column is negative or >= numColumnsIllegalArgumentException
- Width and numColumns has to be positivepublic void setRowHeight(int row, Double height)
row
- The index of the rowheight
- The height of the row. It can be a null if you want to "unset" the heightIndexOutOfBoundsException
- if the row is negative or >= numRowsIllegalArgumentException
- Height has to be positivepublic void setRowHeights(int row, int numRows, Double height)
row
- The index of the rownumRows
- The number of rows to be modified, starting on index.height
- The height of the row. It can be a null if you want to "unset" the rowIndexOutOfBoundsException
- if the row is negative or >= numRowsIllegalArgumentException
- Height has to be positivepublic void showRow(int row)
row
- The index of the rowIndexOutOfBoundsException
- if the row is negative or >= numRowspublic void showColumn(int column)
column
- The index of the rowIndexOutOfBoundsException
- if the column is negative or >= numColumnspublic boolean rowIsHidden(int row)
row
- The index of the rowIndexOutOfBoundsException
- if the row is negative or >= numRowspublic boolean columnIsHidden(int column)
column
- The index of the rowIndexOutOfBoundsException
- if the row is negative or >= numRowspublic boolean isHidden()
public void hideSheet()
public void showSheet()
public Style getDefaultColumnCellStyle(int column)
column
- The index of the columnIndexOutOfBoundsException
- if the column index is invalidpublic void setDefaultColumnCellStyle(int column, Style defaultColumnCellStyle)
column
- The index of the columndefaultColumnCellStyle
- The default cell style of the column. A clone of this object will be stored.IndexOutOfBoundsException
- if the column is negative or >= numColumnsIllegalArgumentException
- if the style is nullpublic int getLastRow()
public int getLastColumn()
public void trim()
public boolean isProtected()
public void setPassword(String key) throws NoSuchAlgorithmException
key
- the password. Sets the password to null to disable the password protectionIllegalArgumentException
- if the password parameter is emptyNoSuchAlgorithmException
- if your java installation doesn't have SHA-256 hash encryptionpublic void setName(String newName)
newName
- The new name of the sheetpublic boolean equals(Object o)
public int compareTo(Sheet o)
compareTo
in interface Comparable<Sheet>
o
- The object to compareCopyright © 2023. All rights reserved.