com.jniwrapper.win32.jexcel
Interface GenericWorkbook

All Known Implementing Classes:
JWorkbook, Workbook

public interface GenericWorkbook

Defines common interface behaviour for excel workbook. Can be implemented by embedded and standalone workbook implementation.


Method Summary
 void activate()
          Activates the workbook.
 void addWorkbookEventListener(WorkbookEventListener eventListener)
          Adds the listener of workbook events.
 Worksheet addWorksheet(java.lang.String name)
          Adds a worksheet to the workbook.
 Worksheet addWorksheet(Worksheet after, java.lang.String name)
          Adds a worksheet to the workbook.
 void copyWorksheet(Worksheet worksheet, Worksheet before, Worksheet after)
          Copies the worksheet to the position after the specified worksheet.
 Worksheet getActiveWorksheet()
          Returns the active worksheet.
 Application getApplication()
          Returns the parent application.
 java.lang.String getAuthor()
          Returns the workbook author name.
 java.io.File getFile()
          Returns the workbook file.
 FileFormat getFileFormat()
          Returns the format of the workbook file.
 java.lang.String getTitle()
          Returns the currently set title of the workbook.
 Window getWindow()
          Returns the windows that corresponds to the workbook.
 java.lang.String getWorkbookName()
          Returns the name of the workbook.
 Worksheet getWorksheet(int index)
          Returns the worksheet that is specified by its index.
 Worksheet getWorksheet(java.lang.String name)
          Returns the worksheet that is specified by its name.
 int getWorksheetCount()
          Returns the number of worksheets in the workbook.
 java.util.List getWorksheets()
          Returns the list of worksheets of the workbook.
 boolean hasPassword()
          Returns true if the workbook has a password.
 boolean isClosed()
          Checks if the workbook is closed.
 boolean isReadOnly()
          Checks if the workbook is read only.
 boolean isSaved()
          Checks if the workbook is saved (have not benn changed since the last save operation).
 void moveWorksheet(Worksheet worksheet, Worksheet after)
          Moves the worksheet to the position after the specified worksheet.
 void print(int copies)
          Prints the specified number of copies of the workbook.
 void print(int firstSheet, int lastSheet, int copies)
          Prints the specified range of worksheet.
 void removeEventHandler()
          Removes the handler of workbook events.
 void removeWorkbookEventListener(WorkbookEventListener eventListener)
          Removes the specified listener of workbook events.
 void removeWorksheet(Worksheet worksheet)
          Removes the worksheet from the workbook.
 void saveCopyAs(java.io.File file)
          Saves a copy of the workbook to another file.
 void setAuthor(java.lang.String author)
          Specifies the workbook author name.
 void setEventHandler(WorkbookEventHandler eventHandler)
          Specifies the handler of workbook events.
 void setPassword(java.lang.String password)
          Sets up a new opening password of the workbook.
 void setTitle(java.lang.String title)
          Sets up the title of the workbook.
 void setWritePassword(java.lang.String password)
          Sets up a new write protection password of the workbook.
 

Method Detail

addWorksheet

public Worksheet addWorksheet(java.lang.String name)
                       throws ExcelException
Adds a worksheet to the workbook.

Parameters:
name - is the name of a new worksheet.
Returns:
the newly added worksheet.
Throws:
java.lang.IllegalStateException - if the workbook is closed.
ExcelException - if a worksheet with such name already exists in the workbook.

addWorksheet

public Worksheet addWorksheet(Worksheet after,
                              java.lang.String name)
                       throws ExcelException
Adds a worksheet to the workbook. The worksheet will be added to the position after the specified worksheet.

Parameters:
after - the worksheet will be added to the position after this worksheet. If the value is null, the worksheet will be added at the beginning of the worksheet list.
name - is the name of a new worksheet.
Returns:
a newly added worksheet.
Throws:
java.lang.IllegalStateException - if the workbook is closed.
ExcelException - if a worksheet with such name already exists in the workbook.

getWorksheet

public Worksheet getWorksheet(java.lang.String name)
Returns the worksheet that is specified by its name. If the specified worksheet was not found, the return value is null.

Parameters:
name - is the name of the worksheet.
Returns:
the worksheet of interest or null if such worksheet is not present.
Throws:
java.lang.IllegalArgumentException - if the name is null.
java.lang.IllegalStateException - if the workbook is closed.

getWorksheets

public java.util.List getWorksheets()
Returns the list of worksheets of the workbook. Each element of the list is an instance of Worksheet class.

Returns:
the list of worksheets.
Throws:
java.lang.IllegalStateException - if the workbook is closed.

getWorksheet

public Worksheet getWorksheet(int index)
Returns the worksheet that is specified by its index.

Parameters:
index - is the index of the worksheet.
Returns:
the worksheet of interest.
Throws:
java.lang.IndexOutOfBoundsException - if there is no worksheet with such index.
java.lang.IllegalStateException - if the workbook is closed.

getActiveWorksheet

public Worksheet getActiveWorksheet()
Returns the active worksheet.

Returns:
the active worksheet.
Throws:
java.lang.IllegalStateException - if the workbook is closed.

setEventHandler

public void setEventHandler(WorkbookEventHandler eventHandler)
Specifies the handler of workbook events.

Parameters:
eventHandler -
Throws:
java.lang.IllegalStateException - if the workbook is closed.

removeEventHandler

public void removeEventHandler()
Removes the handler of workbook events.

Throws:
java.lang.IllegalStateException - if the workbook is closed.

addWorkbookEventListener

public void addWorkbookEventListener(WorkbookEventListener eventListener)
Adds the listener of workbook events.

Parameters:
eventListener -
Throws:
java.lang.IllegalStateException - if the workbook is closed.

removeWorkbookEventListener

public void removeWorkbookEventListener(WorkbookEventListener eventListener)
Removes the specified listener of workbook events.

Parameters:
eventListener - is the listener to be removed.
Throws:
java.lang.IllegalStateException - if the workbook is closed.

setTitle

public void setTitle(java.lang.String title)
Sets up the title of the workbook.

Parameters:
title - is a new title of the workbook.
Throws:
java.lang.IllegalStateException - if the workbook is closed.

getTitle

public java.lang.String getTitle()
Returns the currently set title of the workbook.

Returns:
the currently set title of the workbook.
Throws:
java.lang.IllegalStateException - if the workbook is closed.

getFile

public java.io.File getFile()
Returns the workbook file.

Returns:
the workbook file.
Throws:
java.lang.IllegalStateException - if the workbook is closed.

getFileFormat

public FileFormat getFileFormat()
Returns the format of the workbook file.

Returns:
the format of the workbook file.
Throws:
java.lang.IllegalStateException - if the workbook is closed.

print

public void print(int copies)
           throws javax.print.PrintException
Prints the specified number of copies of the workbook.

Parameters:
copies - is the number of copies to be printed.
Throws:
java.lang.IllegalArgumentException - if the number of copies is negative.
java.lang.IllegalStateException - if the workbook is closed.
javax.print.PrintException - if print problems occured.

print

public void print(int firstSheet,
                  int lastSheet,
                  int copies)
           throws javax.print.PrintException
Prints the specified range of worksheet.

Parameters:
firstSheet - is the index of the first worksheet to be printed.
lastSheet - is the index of the last worksheet to be printed.
copies - is the number of copies to be printed.
Throws:
java.lang.IllegalArgumentException - if the number of copies is negative.
java.lang.IndexOutOfBoundsException - if a worksheet index is illegal.
java.lang.IllegalStateException - if the workbook is closed.
javax.print.PrintException - if print problems occured.

getWorksheetCount

public int getWorksheetCount()
Returns the number of worksheets in the workbook.

Returns:
the number of worksheets in the workbook.
Throws:
java.lang.IllegalStateException - if the workbook is closed.

setPassword

public void setPassword(java.lang.String password)
Sets up a new opening password of the workbook.

Parameters:
password - is a new password to be set up.
Throws:
java.lang.IllegalStateException - if the workbook is closed.

hasPassword

public boolean hasPassword()
Returns true if the workbook has a password.

Returns:
true if the workbook has a password.
Throws:
java.lang.IllegalStateException - if the workbook is closed.

setWritePassword

public void setWritePassword(java.lang.String password)
Sets up a new write protection password of the workbook.

Parameters:
password - is a new write protection password
Throws:
java.lang.IllegalStateException - if the workbook is closed.

getWorkbookName

public java.lang.String getWorkbookName()
Returns the name of the workbook.

Returns:
the name of the workbook.
Throws:
java.lang.IllegalStateException - if the workbook is closed.

isReadOnly

public boolean isReadOnly()
Checks if the workbook is read only.

Returns:
true if the workbook is read only.
Throws:
java.lang.IllegalStateException - if the workbook is closed.

isSaved

public boolean isSaved()
Checks if the workbook is saved (have not benn changed since the last save operation).

Returns:
true if the workbook is saved.
Throws:
java.lang.IllegalStateException - if the workbook is closed.

isClosed

public boolean isClosed()
Checks if the workbook is closed.

Returns:
true if the workbook is closed.

activate

public void activate()
Activates the workbook.

Throws:
java.lang.IllegalStateException - if the workbook is closed.

getWindow

public Window getWindow()
Returns the windows that corresponds to the workbook.

Returns:
the windows that corresponds to the workbook.
Throws:
java.lang.IllegalStateException - if the workbook is closed.
See Also:
Window

getAuthor

public java.lang.String getAuthor()
Returns the workbook author name.

Returns:
the workbook author name.
Throws:
java.lang.IllegalStateException - if the workbook is closed.

setAuthor

public void setAuthor(java.lang.String author)
Specifies the workbook author name.

Parameters:
author - is the workbook author name.
Throws:
java.lang.IllegalStateException - if the workbook is closed.

removeWorksheet

public void removeWorksheet(Worksheet worksheet)
Removes the worksheet from the workbook.

Parameters:
worksheet - specifies the worksheet to be removed.
Throws:
java.lang.IllegalArgumentException - if the target worksheet is null.

moveWorksheet

public void moveWorksheet(Worksheet worksheet,
                          Worksheet after)
Moves the worksheet to the position after the specified worksheet.

Parameters:
worksheet - specifies the worksheet to be moved.
after - the worksheet will be moved to the position after this worksheet. If the value is null, the worksheet will be moved to the beginning of the worksheet list.
Throws:
java.lang.IllegalArgumentException - if any target worksheet if null.

copyWorksheet

public void copyWorksheet(Worksheet worksheet,
                          Worksheet before,
                          Worksheet after)
Copies the worksheet to the position after the specified worksheet.

Parameters:
worksheet - specifies the worksheet to be moved.
before - the worksheet will be moved to the position before this worksheet. If the value is null, after parameter should be specified.
after - the worksheet will be moved to the position after this worksheet. If the value is null, before parameter should be specified.
Throws:
java.lang.IllegalArgumentException - if any target worksheet if null.

getApplication

public Application getApplication()
Returns the parent application.

Returns:
the parent application.

saveCopyAs

public void saveCopyAs(java.io.File file)
                throws java.io.IOException
Saves a copy of the workbook to another file.

Parameters:
file - specifies the file name.
Throws:
java.lang.IllegalStateException - if the workbook is closed.
java.io.IOException - if the workbook cannot be saved to the specified file.