com.jniwrapper.win32.jexcel
Class Application

java.lang.Object
  extended bycom.jniwrapper.win32.jexcel.Application

public class Application
extends java.lang.Object

This class provides functionality for resolving general Excel application tasks.


Field Summary
static com.jniwrapper.Int32 LANGUAGE_NEUTRAL_LCID
           
 
Constructor Summary
Application(com.jniwrapper.win32.excel._Application application, com.jniwrapper.win32.automation.OleMessageLoop messageLoop)
           
Application()
          Creates an instance of Excel application.
 
Method Summary
 void addApplicationEventListener(ApplicationEventListener eventListener)
          Adds the specified application events listener.
 void addToRecentFiles(java.io.File file)
          Adds the specified file to the list of recent files.
 void close()
          Closes the application and all opened workbooks without saving changes.
 Workbook createWorkbook(java.lang.String title)
          Adds a new workbook to the application.
 java.lang.String getActivePrinter()
          Returns the name of the active printer.
 Window getActiveWindow()
          Returns the active window.
 GenericWorkbook getActiveWorkbook()
          Returns the active workbook.
 int getMajorVersionNumber()
          Returns the major version number of MS Excel.
 com.jniwrapper.win32.automation.OleMessageLoop getOleMessageLoop()
          Returns the message loop thread for processing native peer function calls.
 com.jniwrapper.win32.excel._Application getPeer()
          Returns the appropriate native peer.
 java.util.List getRecentFiles()
          Returns the list of recent opened files.
 java.lang.String getVersion(com.jniwrapper.Int32 lcid)
          Returns Excel version as a string value.
 java.util.List getWindows()
          Returns the list of opened windows.
 java.util.List getWorkbooks()
          Returns the list of opened workbooks.
 boolean isClosed()
          Returns true if the application is closed.
 boolean isVisible()
          Returns true if the application is visible or false otherwise.
 Workbook openWorkbook(java.io.File file)
          Opens the specified workbook.
 GenericWorkbook openWorkbook(java.io.File file, boolean readOnly)
          Opens the specified workbook.
 Workbook openWorkbook(java.io.File file, boolean readOnly, java.lang.String password)
          Opens the specified workbook.
 void removeApplicationEventListener(ApplicationEventListener eventListener)
          Removes the specifed application events listener from the list of listeners.
 void setActivePrinter(java.lang.String name)
          Changes the active printer to the specified one.
 void setVisible(boolean visible)
          Shows or hides the application.
 void unadviseHandler()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LANGUAGE_NEUTRAL_LCID

public static final com.jniwrapper.Int32 LANGUAGE_NEUTRAL_LCID
Constructor Detail

Application

public Application()
            throws ExcelException
Creates an instance of Excel application.

Throws:
ExcelException - if the Microsoft Excel application cannot be run.

Application

public Application(com.jniwrapper.win32.excel._Application application,
                   com.jniwrapper.win32.automation.OleMessageLoop messageLoop)
Method Detail

addApplicationEventListener

public void addApplicationEventListener(ApplicationEventListener eventListener)
Adds the specified application events listener.

Parameters:
eventListener -
See Also:
ApplicationEventListener

removeApplicationEventListener

public void removeApplicationEventListener(ApplicationEventListener eventListener)
Removes the specifed application events listener from the list of listeners.

Parameters:
eventListener -
See Also:
ApplicationEventListener

getOleMessageLoop

public com.jniwrapper.win32.automation.OleMessageLoop getOleMessageLoop()
Returns the message loop thread for processing native peer function calls.

Returns:
the message loop thread for processing native peer function calls.

createWorkbook

public Workbook createWorkbook(java.lang.String title)
Adds a new workbook to the application.

Parameters:
title - is a title of the new workbook. May be null.
Returns:
a newly created workbook.

openWorkbook

public Workbook openWorkbook(java.io.File file)
                      throws java.io.FileNotFoundException,
                             ExcelException
Opens the specified workbook.

Parameters:
file - is a workbook file to be opened.
Returns:
an opened workbook.
Throws:
java.lang.IllegalArgumentException - if the target file is not a file
java.io.FileNotFoundException - if the tager file doesn't exist
ExcelException - if the target file has an unsupported format.

openWorkbook

public GenericWorkbook openWorkbook(java.io.File file,
                                    boolean readOnly)
                             throws java.io.FileNotFoundException,
                                    ExcelException
Opens the specified workbook.

Parameters:
file - is a workbook file to be opened.
readOnly - if true the file opens for read only.
Returns:
an opened workbook.
Throws:
java.lang.IllegalArgumentException - if the target file is not a file
java.io.FileNotFoundException - if the tager file doesn't exist
ExcelException - if the target file has an unsupported format.

openWorkbook

public Workbook openWorkbook(java.io.File file,
                             boolean readOnly,
                             java.lang.String password)
                      throws java.io.FileNotFoundException,
                             ExcelException
Opens the specified workbook.

Parameters:
file - is a workbook file to be opened.
readOnly - if true the file opens for read only.
password - specified the password that required for opening the workbook. May be null.
Returns:
an opened workbook.
Throws:
java.lang.IllegalArgumentException - if the target file is not a file
java.io.FileNotFoundException - if the tager file doesn't exist
ExcelException - if the target file has an unsupported format.

getVersion

public java.lang.String getVersion(com.jniwrapper.Int32 lcid)
Returns Excel version as a string value.

Parameters:
lcid - locale id
Returns:
version value

getMajorVersionNumber

public int getMajorVersionNumber()
Returns the major version number of MS Excel.

Returns:
major version number

getWorkbooks

public java.util.List getWorkbooks()
Returns the list of opened workbooks. Each element of the list is an instance of Workbook.

Returns:
the list of opened workbooks.

getWindows

public java.util.List getWindows()
Returns the list of opened windows. Each element of the list is an instance of Window.

Returns:
the list of opened windows.

getActiveWorkbook

public GenericWorkbook getActiveWorkbook()
Returns the active workbook.

Returns:
the active workbook.

getActiveWindow

public Window getActiveWindow()
Returns the active window.

Returns:
the active window.

getRecentFiles

public java.util.List getRecentFiles()
Returns the list of recent opened files. Each element of the list is an instance of File.

Returns:
the list of recent opened files.

addToRecentFiles

public void addToRecentFiles(java.io.File file)
Adds the specified file to the list of recent files.

Parameters:
file - is a file to be added.

getPeer

public com.jniwrapper.win32.excel._Application getPeer()
Returns the appropriate native peer.

Returns:
the appropriate native peer.

setActivePrinter

public void setActivePrinter(java.lang.String name)
                      throws java.awt.print.PrinterException
Changes the active printer to the specified one. The function fails if no workbooks are opened.

Parameters:
name - is the full name of a printer.
Throws:
java.lang.IllegalArgumentException - if the target name is null.
java.awt.print.PrinterException - if the specified printer cannot be set up.

getActivePrinter

public java.lang.String getActivePrinter()
Returns the name of the active printer.

Returns:
the name of the active printer.

setVisible

public void setVisible(boolean visible)
Shows or hides the application.

Parameters:
visible - if true the application become visible.

isVisible

public boolean isVisible()
Returns true if the application is visible or false otherwise.

Returns:
true if the application is visible or false otherwise.

isClosed

public boolean isClosed()
Returns true if the application is closed.

Returns:
true if the application is closed.

unadviseHandler

public void unadviseHandler()

close

public void close()
Closes the application and all opened workbooks without saving changes.