org.jopendocument.dom.spreadsheet
Class SpreadSheet

java.lang.Object
  extended by org.jopendocument.dom.ODDocument
      extended by org.jopendocument.dom.spreadsheet.SpreadSheet

public class SpreadSheet
extends ODDocument

A calc document.

Author:
Sylvain

Method Summary
 Sheet addSheet(int index, java.lang.String name)
          Adds an empty sheet.
 Sheet addSheet(java.lang.String name)
           
static SpreadSheet create(int sheetCount, int colCount, int rowCount)
           
static SpreadSheet create(XMLFormatVersion ns, int sheetCount, int colCount, int rowCount)
           
static SpreadSheet createEmpty(javax.swing.table.TableModel t)
           
static SpreadSheet createEmpty(javax.swing.table.TableModel t, XMLFormatVersion ns)
           
static SpreadSheet createFromFile(java.io.File f)
           
static java.io.File export(javax.swing.table.TableModel t, java.io.File f, XMLFormatVersion ns)
          Export the passed data to file.
static SpreadSheet get(ODPackage fd)
          This method should be avoided, use ODPackage.getSpreadSheet().
 Cell<SpreadSheet> getCellAt(java.lang.String ref)
          Return the cell at the passed address.
 Sheet getFirstSheet()
           
 Range getRange(java.lang.String name)
          Get a global named range.
 java.util.Set<java.lang.String> getRangesNames()
          All global ranges defined in this document.
 Sheet getSheet(int i)
           
 Sheet getSheet(java.lang.String name)
           
 Sheet getSheet(java.lang.String name, boolean mustExist)
          Return the first sheet with the passed name.
 int getSheetCount()
           
 SheetTableModel.MutableTableModel<SpreadSheet> getTableModel(java.lang.String name)
          Return a view of the passed range.
 org.jdom.xpath.XPath getXPath(java.lang.String p)
           
 Tuple2<Sheet,java.awt.Point> resolve(java.lang.String ref)
          Resolve a cell address.
 
Methods inherited from class org.jopendocument.dom.ODDocument
getContentDocument, getEpoch, getEpoch, getFormatVersion, getPackage, getVersion, saveAs
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

createFromFile

public static SpreadSheet createFromFile(java.io.File f)
                                  throws java.io.IOException
Throws:
java.io.IOException

get

public static SpreadSheet get(ODPackage fd)
This method should be avoided, use ODPackage.getSpreadSheet().

Parameters:
fd - a package.
Returns:
the spreadsheet.

createEmpty

public static SpreadSheet createEmpty(javax.swing.table.TableModel t)

createEmpty

public static SpreadSheet createEmpty(javax.swing.table.TableModel t,
                                      XMLFormatVersion ns)

create

public static SpreadSheet create(int sheetCount,
                                 int colCount,
                                 int rowCount)

create

public static SpreadSheet create(XMLFormatVersion ns,
                                 int sheetCount,
                                 int colCount,
                                 int rowCount)

export

public static java.io.File export(javax.swing.table.TableModel t,
                                  java.io.File f,
                                  XMLFormatVersion ns)
                           throws java.io.IOException
Export the passed data to file.

Parameters:
t - the data to export.
f - where to export, if the extension is missing (or wrong) the correct one will be added, eg "dir/data".
ns - the version of XML.
Returns:
the saved file, eg "dir/data.ods".
Throws:
java.io.IOException - if the file can't be saved.

getRangesNames

public final java.util.Set<java.lang.String> getRangesNames()
All global ranges defined in this document.

Returns:
the global names.
See Also:
Table.getRangesNames()

getRange

public final Range getRange(java.lang.String name)
Get a global named range.

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

getTableModel

public final SheetTableModel.MutableTableModel<SpreadSheet> getTableModel(java.lang.String name)
Return a view of the passed range.

Parameters:
name - a global named range.
Returns:
the matching TableModel, null if it doesn't exist.
See Also:
getRange(String), Table.getMutableTableModel(Point, Point)

getCellAt

public final Cell<SpreadSheet> getCellAt(java.lang.String ref)
Return the cell at the passed address.

Parameters:
ref - the full address, eg "$sheet.A12".
Returns:
the cell at the passed address.

resolve

public final Tuple2<Sheet,java.awt.Point> resolve(java.lang.String ref)
Resolve a cell address.

Parameters:
ref - an OpenDocument cell address (see 9.2.1 of OpenDocument-v1.2-cs01-part1), e.g. "table.B2".
Returns:
the table and the cell coordinates.

getXPath

public org.jdom.xpath.XPath getXPath(java.lang.String p)
                              throws org.jdom.JDOMException
Throws:
org.jdom.JDOMException

getSheetCount

public int getSheetCount()

getFirstSheet

public final Sheet getFirstSheet()

getSheet

public Sheet getSheet(int i)

getSheet

public Sheet getSheet(java.lang.String name)

getSheet

public Sheet getSheet(java.lang.String name,
                      boolean mustExist)
               throws java.util.NoSuchElementException
Return the first sheet with the passed name.

Parameters:
name - the name of a sheet.
mustExist - what to do when no match is found : true to throw an exception, false to return null.
Returns:
the first matching sheet, null if mustExist is false and no match is found.
Throws:
java.util.NoSuchElementException - if mustExist is true and no match is found.

addSheet

public final Sheet addSheet(int index,
                            java.lang.String name)
Adds an empty sheet.

Parameters:
index - where to add the new sheet.
name - the name of the new sheet.
Returns:
the newly created sheet.

addSheet

public final Sheet addSheet(java.lang.String name)