org.jopendocument.dom.spreadsheet
Class Table<D extends ODDocument>

java.lang.Object
  extended by org.jopendocument.dom.ODNode
      extended by org.jopendocument.dom.StyledNode<S,D>
          extended by org.jopendocument.dom.ImmutableDocStyledNode<S,D>
              extended by org.jopendocument.dom.spreadsheet.Table<D>
Type Parameters:
D - type of table parent
Direct Known Subclasses:
Sheet

public class Table<D extends ODDocument>
extends ImmutableDocStyledNode<S,D>

A single sheet in a spreadsheet.

Author:
Sylvain

Constructor Summary
Table(D parent, org.jdom.Element local)
           
 
Method Summary
 ColumnStyle createColumnStyle(Number amount, LengthUnit unit)
          Create and add an automatic style.
 void detach()
           
 void duplicateFirstRows(int nbFirstRows, int nbDuplicate)
           
 void duplicateRows(int start, int count, int copies)
          Clone a range of rows.
 void duplicateRows(int start, int count, int copies, boolean updateCellAddresses)
           
 void ensureColumnCount(int newSize)
          Assure that this sheet has at least newSize columns.
 void ensureRowCount(int newSize)
           
 MutableCell<D> getCellAt(int x, int y)
          Return a modifiable cell at the passed coordinates.
 MutableCell<D> getCellAt(String ref)
           
protected  StyleStyleDesc<CellStyle> getCellStyleDesc()
           
 Column<D> getColumn(int i)
           
 int getColumnCount()
           
 TableGroup getColumnGroup()
           
 TableGroup getColumnGroupAt(int x)
          Return the deepest group at the passed column.
protected  StyleStyleDesc<ColumnStyle> getColumnStyleDesc()
           
 Point getCoverOrigin(int x, int y)
          Return the origin of a merged cell.
 Range getCurrentRegion(int startX, int startY)
          The smallest range containing the passed cell completely surrounded by empty rows and columns.
 Range getCurrentRegion(int startX, int startY, boolean checkStyle)
           
 Range getCurrentRegion(String ref)
           
 Range getCurrentRegion(String ref, boolean checkStyle)
           
 CellStyle getDefaultCellStyle()
           
 int getHeaderColumnCount()
           
 int getHeaderRowCount()
           
 Cell<D> getImmutableCellAt(int x, int y)
          Return a non modifiable cell at the passed coordinates.
 Cell<D> getImmutableCellAt(String ref)
           
 SheetTableModel.MutableTableModel<D> getMutableTableModel(int column, int row)
           
 SheetTableModel.MutableTableModel<D> getMutableTableModel(Point start, Point end)
          Return the table from start to end inclusive.
 String getName()
           
 Object getPrintRanges()
           
 Range getRange(String name)
          Get a named range in this table.
 Set<String> getRangesNames()
          All ranges defined in this table.
 int getRowCount()
           
 TableGroup getRowGroup()
           
 TableGroup getRowGroupAt(int y)
          Return the deepest group at the passed row.
protected  StyleStyleDesc<RowStyle> getRowStyleDesc()
           
 CellStyle getStyleAt(int column, int row)
           
 String getStyleNameAt(int column, int row)
          Find the style name for the specified cell.
 List<Tuple2<Integer,Integer>> getStyleReferences(String cellStyleName)
          Return the coordinates of cells using the passed style.
protected  org.jdom.Namespace getTABLE()
           
 CellStyle.StyleTableCellProperties getTableCellPropertiesAt(int column, int row)
           
 SheetTableModel<D> getTableModel(int column, int row)
           
 SheetTableModel<D> getTableModel(int column, int row, int lastCol, int lastRow)
           
 SheetTableModel.MutableTableModel<D> getTableModel(String name)
           
 Range getUsedRange()
          The range that covers all used cells.
 Range getUsedRange(boolean checkStyle)
          The range that covers all used cells.
 Object getValueAt(int column, int row)
           
 Object getValueAt(String ref)
          Retourne la valeur de la cellule spécifiée.
 Float getWidth()
          Table width.
 void insertDuplicatedRows(int rowDuplicated, int nbDuplicate)
           
protected  boolean isCellBlank(int x, int y, boolean checkStyle)
           
 boolean isCellValid(int x, int y)
           
 void merge(TableModel t, int column, int row)
           
 void merge(TableModel t, int column, int row, boolean includeColNames)
          Merges t into this sheet at the specified point.
 void removeColumn(int colIndex, boolean keepTableWidth)
           
 void removeColumn(int firstIndex, int lastIndex, boolean keepTableWidth)
          Remove columns from this.
 void removePrintRanges()
           
 void removeRow(int index)
           
 void removeRows(int firstIndex, int lastIndex)
          Remove rows between the two passed indexes.
 Point resolveHint(String ref)
           
 void setColumnCount(int newSize)
          Changes the column count without keeping the table width.
 void setColumnCount(int newSize, ColumnStyle colStyle, boolean keepTableWidth)
          Changes the column count.
 void setColumnCount(int newSize, int colIndex, boolean keepTableWidth)
          Changes the column count.
 void setName(String name)
           
 void setPrintRanges(String s)
           
 void setRowCount(int newSize)
           
 void setRowCount(int newSize, int rowIndex)
          Changes the row count.
 void setValueAt(Object val, int x, int y)
          Sets the value at the specified coordinates.
static String toStr(int col)
           
 
Methods inherited from class org.jopendocument.dom.ImmutableDocStyledNode
getContent, getODDocument
 
Methods inherited from class org.jopendocument.dom.StyledNode
getPrivateStyle, getStyle, getStyle, getStyle, getStyle, getStyleDesc, getStyleDesc, getStyleDesc, getStyleName, getStyleStyleDesc, setStyleName, setStyleName
 
Methods inherited from class org.jopendocument.dom.ODNode
getElement, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Table

public Table(D parent,
             org.jdom.Element local)
Method Detail

getName

public final String getName()

setName

public final void setName(String name)

detach

public void detach()

getPrintRanges

public final Object getPrintRanges()

setPrintRanges

public final void setPrintRanges(String s)

removePrintRanges

public final void removePrintRanges()

duplicateFirstRows

public final void duplicateFirstRows(int nbFirstRows,
                                     int nbDuplicate)

insertDuplicatedRows

public final void insertDuplicatedRows(int rowDuplicated,
                                       int nbDuplicate)

duplicateRows

public final void duplicateRows(int start,
                                int count,
                                int copies)
Clone a range of rows. Eg if you want to copy once rows 2 through 5, you call duplicateRows(2, 4, 1).

Parameters:
start - the first row to clone.
count - the number of rows after start to clone.
copies - the number of copies of the range to make.

duplicateRows

public final void duplicateRows(int start,
                                int count,
                                int copies,
                                boolean updateCellAddresses)

resolveHint

public final Point resolveHint(String ref)

isCellValid

public final boolean isCellValid(int x,
                                 int y)

getCellAt

public final MutableCell<D> getCellAt(int x,
                                      int y)
Return a modifiable cell at the passed coordinates. This is slower than getImmutableCellAt(int, int) since this method may modify the underlying XML (e.g. break up repeated cells to allow for modification of only the returned cell).

Parameters:
x - the column.
y - the row.
Returns:
the cell.
See Also:
getImmutableCellAt(int, int)

getCellAt

public final MutableCell<D> getCellAt(String ref)

setValueAt

public final void setValueAt(Object val,
                             int x,
                             int y)
Sets the value at the specified coordinates.

Parameters:
val - the new value, null will be treated as "".
x - the column.
y - the row.

getImmutableCellAt

public final Cell<D> getImmutableCellAt(int x,
                                        int y)
Return a non modifiable cell at the passed coordinates. This is faster than getCellAt(int, int) since this method never modifies the underlying XML.

Parameters:
x - the column.
y - the row.
Returns:
the cell.
See Also:
getCellAt(int, int)

getImmutableCellAt

public final Cell<D> getImmutableCellAt(String ref)

getCoverOrigin

public final Point getCoverOrigin(int x,
                                  int y)
Return the origin of a merged cell.

Parameters:
x - the column.
y - the row.
Returns:
the point of origin, null if there's no merged cell at the passed coordinates.

getValueAt

public final Object getValueAt(int column,
                               int row)
Parameters:
row - la ligne (0 a lineCount-1)
column - la colonnee (0 a colonneCount-1)
Returns:
la valeur de la cellule spécifiée.

getStyleNameAt

public final String getStyleNameAt(int column,
                                   int row)
Find the style name for the specified cell.

Parameters:
column - column index.
row - row index.
Returns:
the style name, can be null.

getStyleAt

public final CellStyle getStyleAt(int column,
                                  int row)

getTableCellPropertiesAt

public final CellStyle.StyleTableCellProperties getTableCellPropertiesAt(int column,
                                                                         int row)

getCellStyleDesc

protected StyleStyleDesc<CellStyle> getCellStyleDesc()

getDefaultCellStyle

public final CellStyle getDefaultCellStyle()

getStyleReferences

public final List<Tuple2<Integer,Integer>> getStyleReferences(String cellStyleName)
Return the coordinates of cells using the passed style.

Parameters:
cellStyleName - a style name.
Returns:
the cells using cellStyleName.

getColumnStyleDesc

protected final StyleStyleDesc<ColumnStyle> getColumnStyleDesc()

getRowStyleDesc

protected final StyleStyleDesc<RowStyle> getRowStyleDesc()

getValueAt

public final Object getValueAt(String ref)
Retourne la valeur de la cellule spécifiée.

Parameters:
ref - une référence de la forme "A3".
Returns:
la valeur de la cellule spécifiée.

getColumn

public final Column<D> getColumn(int i)

getRowCount

public final int getRowCount()

getRowGroup

public final TableGroup getRowGroup()

getRowGroupAt

public final TableGroup getRowGroupAt(int y)
Return the deepest group at the passed row.

Parameters:
y - a row index.
Returns:
the group at the index, never null.

getHeaderRowCount

public final int getHeaderRowCount()

getColumnCount

public final int getColumnCount()

getColumnGroup

public final TableGroup getColumnGroup()

getColumnGroupAt

public final TableGroup getColumnGroupAt(int x)
Return the deepest group at the passed column.

Parameters:
x - a column index.
Returns:
the group at the index, never null.

getHeaderColumnCount

public final int getHeaderColumnCount()

setColumnCount

public final void setColumnCount(int newSize)
Changes the column count without keeping the table width.

Parameters:
newSize - the new column count.
See Also:
setColumnCount(int, int, boolean)

ensureColumnCount

public final void ensureColumnCount(int newSize)
Assure that this sheet has at least newSize columns.

Parameters:
newSize - the minimum column count this table should have.

setColumnCount

public final void setColumnCount(int newSize,
                                 int colIndex,
                                 boolean keepTableWidth)
Changes the column count. If newSize is less than getColumnCount() extra cells will be chopped off. Otherwise empty cells will be created.

Parameters:
newSize - the new column count.
colIndex - the index of the column to be copied, -1 for empty column (and no style).
keepTableWidth - true if the table should be same width after the column change.

setColumnCount

public final void setColumnCount(int newSize,
                                 ColumnStyle colStyle,
                                 boolean keepTableWidth)
Changes the column count. If newSize is less than getColumnCount() extra cells will be chopped off. Otherwise empty cells will be created.

Parameters:
newSize - the new column count.
colStyle - the style of the new columns, null for no style (throws exception if the table has a non-null width).
keepTableWidth - true if the table should be same width after the column change.
See Also:
createColumnStyle(Number, LengthUnit)

removeColumn

public final void removeColumn(int colIndex,
                               boolean keepTableWidth)

removeColumn

public final void removeColumn(int firstIndex,
                               int lastIndex,
                               boolean keepTableWidth)
Remove columns from this. As with OpenOffice, no cell must be covered in the column to remove. ATTN keepTableWidth only works for tables in text document that are not aligned automatically (ie fill the entire page). ATTN spreadsheet applications may hide from you the real width of sheets, eg display only columns A to AJ when in reality there's hundreds of blank columns beyond. Thus if you pass true to keepTableWidth you'll end up with huge widths.

Parameters:
firstIndex - the first column to remove.
lastIndex - the last column to remove, exclusive.
keepTableWidth - true if the table should be same width after the column change.

getWidth

public final Float getWidth()
Table width.

Returns:
the table width, can be null (table has no style or style has no width, eg in SpreadSheet).

createColumnStyle

public final ColumnStyle createColumnStyle(Number amount,
                                           LengthUnit unit)
Create and add an automatic style.

Parameters:
amount - the column width.
unit - the unit of amount.
Returns:
the newly added style.

ensureRowCount

public final void ensureRowCount(int newSize)

setRowCount

public final void setRowCount(int newSize)

setRowCount

public final void setRowCount(int newSize,
                              int rowIndex)
Changes the row count. If newSize is less than getRowCount() extra rows will be chopped off. Otherwise empty cells will be created.

Parameters:
newSize - the new row count.
rowIndex - the index of the row to be copied, -1 for empty row (i.e. default style).

removeRow

public final void removeRow(int index)

removeRows

public final void removeRows(int firstIndex,
                             int lastIndex)
Remove rows between the two passed indexes. If the origin of a merged cell is contained in the rows to remove, then it will be unmerged, otherwise (the origin is before the rows) the merged cell will just be shrunk.

Parameters:
firstIndex - the start index, inclusive.
lastIndex - the stop index, exclusive.

getTableModel

public final SheetTableModel<D> getTableModel(int column,
                                              int row)

getTableModel

public final SheetTableModel<D> getTableModel(int column,
                                              int row,
                                              int lastCol,
                                              int lastRow)

getMutableTableModel

public final SheetTableModel.MutableTableModel<D> getMutableTableModel(int column,
                                                                       int row)

getMutableTableModel

public final SheetTableModel.MutableTableModel<D> getMutableTableModel(Point start,
                                                                       Point end)
Return the table from start to end inclusive.

Parameters:
start - the first cell of the result.
end - the last cell of the result.
Returns:
the table.

merge

public final void merge(TableModel t,
                        int column,
                        int row)

merge

public final void merge(TableModel t,
                        int column,
                        int row,
                        boolean includeColNames)
Merges t into this sheet at the specified point.

Parameters:
t - the data to be merged.
column - the column t will be merged at.
row - the row t will be merged at.
includeColNames - if true the column names of t will also be merged.

getRangesNames

public final Set<String> getRangesNames()
All ranges defined in this table.

Returns:
the names.
See Also:
SpreadSheet.getRangesNames()

getRange

public final Range getRange(String name)
Get a named range in this table.

Parameters:
name - the name of the range.
Returns:
a named range, or null if the passed name doesn't exist.
See Also:
getRangesNames(), SpreadSheet.getRange(String)

getTableModel

public final SheetTableModel.MutableTableModel<D> getTableModel(String name)

getUsedRange

public final Range getUsedRange()
The range that covers all used cells.

Returns:
the range that covers all used cells, null if the table is completely empty.

getUsedRange

public final Range getUsedRange(boolean checkStyle)
The range that covers all used cells.

Parameters:
checkStyle - true to check the background and borders in addition to the content.
Returns:
the range that covers all used cells, null if the table is completely blank.

isCellBlank

protected final boolean isCellBlank(int x,
                                    int y,
                                    boolean checkStyle)

getCurrentRegion

public final Range getCurrentRegion(String ref)

getCurrentRegion

public final Range getCurrentRegion(String ref,
                                    boolean checkStyle)

getCurrentRegion

public final Range getCurrentRegion(int startX,
                                    int startY)
The smallest range containing the passed cell completely surrounded by empty rows and columns.

Parameters:
startX - x coordinate.
startY - y coordinate.
Returns:
the smallest range containing the passed cell.
See Also:
CurrentRegion Property

getCurrentRegion

public final Range getCurrentRegion(int startX,
                                    int startY,
                                    boolean checkStyle)

toStr

public static final String toStr(int col)

getTABLE

protected final org.jdom.Namespace getTABLE()


Copyright © 2010 jOpenDocument All Rights Reserved.