Holger's
Java API

com.antelmann.ooffice
Class SpreadsheetFrame

java.lang.Object
  extended by com.antelmann.ooffice.SpreadsheetFrame
All Implemented Interfaces:
ThirdParty, Closeable

public class SpreadsheetFrame
extends Object
implements ThirdParty, Closeable

simplifies handling of OpenOffice spreadsheets This class implements ThirdParty for its use of OpenOffice libraries; see www.openoffice.org

Author:
Holger Antelmann

Nested Class Summary
static class SpreadsheetFrame.CellFormat
          used to format a cell value
 
Constructor Summary
SpreadsheetFrame()
          creates a blank new spreadsheet
SpreadsheetFrame(File template)
          creates a new document based on the given template file
SpreadsheetFrame(File file, Properties props)
          loads a document (the given file) into a blank frame along with the given properties
 
Method Summary
 void close()
          closes and disposes the document
 void copySheet(String origin, String target, short index)
           
static String defaultExtension()
           
static SpreadsheetFrame getActiveDocument()
          seeks the currently active document on the desktop (if any) and returns it
static String getCellAddressString(int row, int column)
           
 String getCellFormula(String sheet, int row, int column)
           
 com.sun.star.sheet.XSpreadsheetDocument getDocument()
           
 com.sun.star.sheet.XSpreadsheet getSheet(int index)
           
 com.sun.star.sheet.XSpreadsheet getSheet(String name)
           
 String[] getSheetNames()
           
 void insertNewSheet(String name, short index)
           
 void moveSheetToIndex(String name, short index)
           
 void placeTableModel(TableModel model, String sheet, int row, int column)
          places the given model into the spreadsheet with the upper left corner at the given location using a variety of useful default cell formats
 void print()
           
 void print(String printerName)
           
 void setCellDate(String sheet, int row, int column, Date date)
           
 void setCellDateTime(String sheet, int row, int column, Date date)
           
 void setCellFormula(String sheet, int row, int column, String formula)
           
 void setCellTime(String sheet, int row, int column, Date date)
           
 void setCellTime(String sheet, int row, int column, TimeInDay time)
           
 void setCellValue(String sheet, int row, int column, double value)
           
 void setCellValue(String sheet, int row, int column, Object value)
          makes a best effort to set the cell's value using an appropriate format
 void setCellValue(String sheet, int row, int column, String value, SpreadsheetFrame.CellFormat format)
          sheet, value, format must not be null
 void storeTo(File file, boolean representNewLocation)
          saves the embedded document to the given file (overwriting it, if it exists)
 void storeTo(File file, String filterName, boolean representNewLocation)
          saves the given document to the given file (overwriting it, if it exists) in the given format
 void storeTo(String url, boolean representNewLocation)
          saves the given document to the given url (overwriting the url if it exists)
 void storeTo(String url, String filterName, boolean representNewLocation)
          allows to specify a filterName that defines the output format (null is allowed).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SpreadsheetFrame

public SpreadsheetFrame()
                 throws OfficeException
creates a blank new spreadsheet

Throws:
OfficeException

SpreadsheetFrame

public SpreadsheetFrame(File template)
                 throws OfficeException,
                        IOException
creates a new document based on the given template file

Throws:
OfficeException
IOException

SpreadsheetFrame

public SpreadsheetFrame(File file,
                        Properties props)
                 throws OfficeException,
                        IOException
loads a document (the given file) into a blank frame along with the given properties

Throws:
OfficeException
IOException
Method Detail

getActiveDocument

public static SpreadsheetFrame getActiveDocument()
                                          throws OfficeException
seeks the currently active document on the desktop (if any) and returns it

Throws:
OfficeException

getDocument

public com.sun.star.sheet.XSpreadsheetDocument getDocument()

getSheetNames

public String[] getSheetNames()

getSheet

public com.sun.star.sheet.XSpreadsheet getSheet(int index)
                                         throws OfficeException
Throws:
OfficeException

getSheet

public com.sun.star.sheet.XSpreadsheet getSheet(String name)
                                         throws OfficeException,
                                                IllegalArgumentException
Throws:
OfficeException
IllegalArgumentException

setCellValue

public void setCellValue(String sheet,
                         int row,
                         int column,
                         double value)
                  throws OfficeException
Throws:
OfficeException

setCellFormula

public void setCellFormula(String sheet,
                           int row,
                           int column,
                           String formula)
                    throws OfficeException
Throws:
OfficeException

setCellDate

public void setCellDate(String sheet,
                        int row,
                        int column,
                        Date date)
                 throws OfficeException,
                        IllegalArgumentException
Throws:
OfficeException
IllegalArgumentException

setCellTime

public void setCellTime(String sheet,
                        int row,
                        int column,
                        TimeInDay time)
                 throws OfficeException,
                        IllegalArgumentException
Throws:
OfficeException
IllegalArgumentException

setCellTime

public void setCellTime(String sheet,
                        int row,
                        int column,
                        Date date)
                 throws OfficeException,
                        IllegalArgumentException
Throws:
OfficeException
IllegalArgumentException

setCellDateTime

public void setCellDateTime(String sheet,
                            int row,
                            int column,
                            Date date)
                     throws OfficeException,
                            IllegalArgumentException
Throws:
OfficeException
IllegalArgumentException

setCellValue

public void setCellValue(String sheet,
                         int row,
                         int column,
                         Object value)
                  throws OfficeException
makes a best effort to set the cell's value using an appropriate format

Throws:
OfficeException

setCellValue

public void setCellValue(String sheet,
                         int row,
                         int column,
                         String value,
                         SpreadsheetFrame.CellFormat format)
                  throws OfficeException,
                         IllegalArgumentException
sheet, value, format must not be null

Throws:
OfficeException
IllegalArgumentException

getCellFormula

public String getCellFormula(String sheet,
                             int row,
                             int column)
                      throws OfficeException,
                             IllegalArgumentException
Throws:
OfficeException
IllegalArgumentException

placeTableModel

public void placeTableModel(TableModel model,
                            String sheet,
                            int row,
                            int column)
                     throws OfficeException
places the given model into the spreadsheet with the upper left corner at the given location using a variety of useful default cell formats

Throws:
OfficeException

getCellAddressString

public static String getCellAddressString(int row,
                                          int column)

copySheet

public void copySheet(String origin,
                      String target,
                      short index)

moveSheetToIndex

public void moveSheetToIndex(String name,
                             short index)

insertNewSheet

public void insertNewSheet(String name,
                           short index)

defaultExtension

public static String defaultExtension()

storeTo

public void storeTo(File file,
                    boolean representNewLocation)
             throws IOException
saves the embedded document to the given file (overwriting it, if it exists)

Throws:
IOException

storeTo

public void storeTo(File file,
                    String filterName,
                    boolean representNewLocation)
             throws IOException
saves the given document to the given file (overwriting it, if it exists) in the given format

Throws:
IOException

storeTo

public void storeTo(String url,
                    boolean representNewLocation)
             throws IOException
saves the given document to the given url (overwriting the url if it exists)

Throws:
IOException

storeTo

public void storeTo(String url,
                    String filterName,
                    boolean representNewLocation)
             throws IOException
allows to specify a filterName that defines the output format (null is allowed). Known filterNames include:

close

public void close()
           throws IOException
closes and disposes the document

Specified by:
close in interface Closeable
Throws:
IOException

print

public void print()
           throws OfficeException
Throws:
OfficeException

print

public void print(String printerName)
           throws IllegalArgumentException
Throws:
IllegalArgumentException


(c) 2001-2006 Holger Antelmann - all rights reserved (contact: info@antelmann.com)
see www.antelmann.com/developer for further details and available downloads