org.jopendocument.dom.spreadsheet
Class SpreadSheet

java.lang.Object
  extended by org.jopendocument.dom.spreadsheet.SpreadSheet
All Implemented Interfaces:
ODDocument

public class SpreadSheet
extends Object
implements ODDocument

A calc document.

Author:
Sylvain

Constructor Summary
SpreadSheet(org.jdom.Document doc, org.jdom.Document styles)
           
 
Method Summary
 Sheet addSheet(int index, String name)
          Adds an empty sheet.
 Sheet addSheet(String name)
           
static SpreadSheet create(ODPackage fd)
           
static SpreadSheet createEmpty(TableModel t)
           
static SpreadSheet createEmpty(TableModel t, XMLVersion ns)
           
static SpreadSheet createFromFile(File f)
           
static File export(TableModel t, File f, XMLVersion ns)
          Export the passed data to file.
 Cell<SpreadSheet> getCellAt(String ref)
          Return the cell at the passed address.
 ODPackage getPackage()
           
 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.
 XMLVersion getVersion()
           
 org.jdom.xpath.XPath getXPath(String p)
           
protected  String parseSheetName(String n)
           
 File saveAs(File file)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SpreadSheet

public SpreadSheet(org.jdom.Document doc,
                   org.jdom.Document styles)
Method Detail

createFromFile

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

create

public static SpreadSheet create(ODPackage fd)

createEmpty

public static SpreadSheet createEmpty(TableModel t)
                               throws IOException
Throws:
IOException

createEmpty

public static SpreadSheet createEmpty(TableModel t,
                                      XMLVersion ns)
                               throws IOException
Throws:
IOException

export

public static File export(TableModel t,
                          File f,
                          XMLVersion 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.

getVersion

public final XMLVersion getVersion()
Specified by:
getVersion in interface ODDocument

parseSheetName

protected final String parseSheetName(String n)

getTableModel

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

Parameters:
name - a named range.
Returns:
the matching TableModel, null if it doesn't exist.

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.

getXPath

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

getSheetCount

public int getSheetCount()

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)

saveAs

public File saveAs(File file)
            throws FileNotFoundException,
                   IOException
Throws:
FileNotFoundException
IOException

getPackage

public final ODPackage getPackage()
Specified by:
getPackage in interface ODDocument


Copyright © 2010 jOpenDocument All Rights Reserved.