com.jniwrapper.win32.jexcel
Class Application

java.lang.Object
  extended bycom.jniwrapper.win32.jexcel.BaseWrapper
      extended bycom.jniwrapper.win32.jexcel.Application
All Implemented Interfaces:
com.jniwrapper.AutoDeleteParameter

public class Application
extends com.jniwrapper.win32.jexcel.BaseWrapper

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.
protected  void addChildResource(com.jniwrapper.win32.jexcel.ApplicationAwareWrapper wrapper)
          Adds a specified resource to the managed collection.
 void addToRecentFiles(java.io.File file)
          Adds the specified file to the list of recent files.
 void allowMacros(boolean allow)
          Restricts or allows macros execution in uploaded workbook.
 void close()
          Closes the application and all opened workbooks without saving changes and without calling Application's quit() method.
 void close(boolean forceQuit)
          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.
 boolean getDisplayAlerts()
          Checks whether Excel alerts are enabled or disabled.
 int getMajorVersionNumber()
          Returns the major version number of MS Excel.
 com.jniwrapper.win32.excel.Name[] getNames()
          Returns array of names.
 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.
 Range getSelection()
          Returns selection.
 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 isAutoDelete()
           
 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.
 Workbook 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.
 Workbook openWorkbook(java.io.File file, boolean readOnly, java.lang.String password, java.lang.String writeResPassword)
          Opens the specified workbook.
 void quit()
          Quits this application.
 void removeApplicationEventListener(ApplicationEventListener eventListener)
          Removes the specified application events listener from the list of listeners.
protected  void removeChildResource(com.jniwrapper.win32.jexcel.ApplicationAwareWrapper wrapper)
          Removes a specified resource to the managed collection.
 void setActivePrinter(java.lang.String name)
          Changes the active printer to the specified one.
 void setAutoDelete(boolean value)
           
 void setDisplayAlerts(boolean value)
          Allows or disallows disabling the Excel alerts depending of the specified parameters.
protected  void setOleMessageLoop(com.jniwrapper.win32.automation.OleMessageLoop oleMessageLoop)
           
 void setVisible(boolean visible)
          Shows or hides the application.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, 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 - event listener
See Also:
ApplicationEventListener

removeApplicationEventListener

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

Parameters:
eventListener - event listener
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.

allowMacros

public void allowMacros(boolean allow)
Restricts or allows macros execution in uploaded workbook.

Parameters:
allow - - execution security state

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 target file doesn't exist
ExcelException - if the target file has an unsupported format.

openWorkbook

public Workbook 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 target 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 target 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,
                             java.lang.String writeResPassword)
                      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.
writeResPassword - specified the password that required for opening workbook for changes. May be null.
Returns:
an opened workbook.
Throws:
java.lang.IllegalArgumentException - if the target file is not a file
java.io.FileNotFoundException - if the target 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.

addChildResource

protected void addChildResource(com.jniwrapper.win32.jexcel.ApplicationAwareWrapper wrapper)
Adds a specified resource to the managed collection.

Parameters:
wrapper - child resource.

removeChildResource

protected void removeChildResource(com.jniwrapper.win32.jexcel.ApplicationAwareWrapper wrapper)
Removes a specified resource to the managed collection.

Parameters:
wrapper - child resource.

quit

public void quit()
Quits this application.


close

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

Parameters:
forceQuit - determines whether to call application's quit method.

close

public void close()
Closes the application and all opened workbooks without saving changes and without calling Application's quit() method.


setDisplayAlerts

public void setDisplayAlerts(boolean value)
Allows or disallows disabling the Excel alerts depending of the specified parameters.

Parameters:
value - true allows to display alerts; false otherwise

getDisplayAlerts

public boolean getDisplayAlerts()
Checks whether Excel alerts are enabled or disabled.

Returns:
true if alerts are allowed; false otherwise

getSelection

public Range getSelection()
Returns selection.

Returns:
selection range; null if application does not have a selection

getNames

public com.jniwrapper.win32.excel.Name[] getNames()
Returns array of names.

Returns:
array of names or null if there are no names

setOleMessageLoop

protected void setOleMessageLoop(com.jniwrapper.win32.automation.OleMessageLoop oleMessageLoop)

setAutoDelete

public void setAutoDelete(boolean value)
Specified by:
setAutoDelete in interface com.jniwrapper.AutoDeleteParameter

isAutoDelete

public boolean isAutoDelete()
Specified by:
isAutoDelete in interface com.jniwrapper.AutoDeleteParameter

toString

public java.lang.String toString()