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

Method Detail

createFromFile

public static SpreadSheet createFromFile(File f)
                                  throws IOException
Throws:
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(TableModel t)

createEmpty

public static SpreadSheet createEmpty(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 File export(TableModel t,
                          File f,
                          XMLFormatVersion ns)
                   throws 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:
IOException - if the file can't be saved.

parseSheetName

protected static final String parseSheetName(String n)

formatSheetName

protected static final String formatSheetName(String n)

getRangesNames

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

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

getRange

public final Range getRange(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(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(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,Point> resolve(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(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(String name)

getSheet

public Sheet getSheet(String name,
                      boolean mustExist)
               throws 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:
NoSuchElementException - if mustExist is true and no match is found.

addSheet

public final Sheet addSheet(int index,
                            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(String name)


Copyright © 2010 jOpenDocument All Rights Reserved.