|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
com.jniwrapper.win32.jexcel.ui.JWorkbook
public class JWorkbook
This class provides functionality for embedding Excel workbook into a Java Swing application as an ordinary Swing component.
Nested Class Summary | |
---|---|
static class |
JWorkbook.WorkbookContainer
|
Nested classes/interfaces inherited from class javax.swing.JComponent |
---|
javax.swing.JComponent.AccessibleJComponent |
Nested classes/interfaces inherited from class java.awt.Container |
---|
java.awt.Container.AccessibleAWTContainer |
Nested classes/interfaces inherited from class java.awt.Component |
---|
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy |
Field Summary |
---|
Fields inherited from class javax.swing.JComponent |
---|
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW |
Fields inherited from class java.awt.Component |
---|
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
Fields inherited from interface java.awt.image.ImageObserver |
---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
Constructor Summary | |
---|---|
JWorkbook()
Creates an instance of JWorkbook component. |
|
JWorkbook(boolean staticView)
Creates an instance of JWorkbook component. |
|
JWorkbook(java.io.File workbook)
Creates an instance of JWorkbook component and displays the specified Excel workbook. |
|
JWorkbook(java.io.File workbook,
boolean staticView)
Creates an instance of JWorkbook component and displays the specified Excel workbook. |
Method Summary | |
---|---|
void |
activate()
Activates an embedded workbook. |
void |
addJWorkbookEventListener(JWorkbookEventListener eventListener)
Add a listener of the embedded workbook events. |
void |
addPrintPreviewListener(PrintPreviewListener l)
|
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 |
close()
Closes an embedded workbook. |
void |
copyWorksheet(Worksheet worksheet,
Worksheet before,
Worksheet after)
Copies the worksheet to the position after the specified worksheet. |
void |
deactivate()
Deactivates an embedded workbook ui. |
Worksheet |
getActiveWorksheet()
Returns the active worksheet. |
Application |
getApplication()
Returns the parent application. |
java.lang.String |
getAuthor()
Returns the workbook author name. |
JWorkbook.WorkbookContainer |
getContainer()
Return office container of this workbook. |
java.io.File |
getFile()
If an embedded workbook has been loaded from a file or a new workbook has been saved, then the function returns the workbook file, otherwise it returns null . |
FileFormat |
getFileFormat()
Returns the format of the workbook file. |
com.jniwrapper.win32.automation.OleMessageLoop |
getOleMessageLoop()
Returns ole message loop of workbook. |
java.lang.String |
getTitle()
Returns workbook title. |
Window |
getWindow()
Returns the windows that corresponds to the workbook. |
Workbook |
getWorkbook()
Returns an Excel workbook that is currently opened. |
java.lang.String |
getWorkbookName()
Returns workbook name. |
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 number of worksheets in the workbook. |
java.util.List |
getWorksheets()
Returns the list of worksheets of the workbook. |
boolean |
hasPassword()
Returns "is workbook password protected" status |
boolean |
isActive()
Returns "is workbook active" status |
boolean |
isClosed()
Returns "is workbook closed" status. |
boolean |
isPrintPreview()
Returns true if the component is in the preview mode. |
boolean |
isReadOnly()
Returns "is workbook readonly" status. |
boolean |
isSaved()
Returns "is workbook saved" status |
boolean |
isStaticMode()
Returns true if the workbook is displayed in a static mode and false otherwise. |
boolean |
isWorkbookCreated()
Returns status of embedded Excel workbook. |
void |
moveWorksheet(Worksheet worksheet,
Worksheet after)
Moves the worksheet to the position after the specified worksheet. |
void |
newWorkbook()
Creates a new workbook in the container. |
void |
notifyPrintPreviewStateChanged()
|
void |
onPrintPreview()
|
void |
onPrintPreviewExit()
|
void |
openWorkbook(java.io.File workbookFile)
Opens the specified Excel workbookFile in the container. |
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 |
removeJWorkbookEventListener(JWorkbookEventListener eventListener)
Removes the specified event listener. |
void |
removePrintPreviewListener(PrintPreviewListener l)
|
void |
removeWorkbookEventListener(WorkbookEventListener eventListener)
Removes the specified listener of workbook events. |
void |
removeWorksheet(Worksheet worksheet)
Removes the worksheet from the workbook. |
void |
save()
|
void |
saveAs(java.io.File file,
FileFormat fileFormat,
boolean overwrite)
|
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. |
protected void |
setContainer(JWorkbook.WorkbookContainer container)
|
void |
setEventHandler(WorkbookEventHandler eventHandler)
Specifies the handler of workbook events. |
void |
setPassword(java.lang.String password)
Allows setting workbook password. |
void |
setPrintPreview(boolean value)
Switches the workbook to the print preview mode and back. |
void |
setStaticMode(boolean value)
Changes the embedded workbook displaying mode. |
void |
setTitle(java.lang.String title)
Sets up the title of the workbook. |
void |
setWritePassword(java.lang.String password)
Allows setting write protection password. |
void |
showPrintDialog()
Displays print dialog. |
Methods inherited from class javax.swing.JComponent |
---|
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUI |
Methods inherited from class java.awt.Container |
---|
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree |
Methods inherited from class java.awt.Component |
---|
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public JWorkbook() throws ExcelException
ExcelException
- if Excel cannot be run.public JWorkbook(boolean staticView) throws ExcelException
staticView
- specifies whether the embedded workbook has active UI or not. If true
the workbook will be displayed in the static (not active) mode.
ExcelException
- if Excel cannot be run.setStaticMode(boolean)
public JWorkbook(java.io.File workbook) throws java.io.FileNotFoundException, ExcelException
workbook
- is an Excel workbook file.
ExcelException
- if Excel cannot be run.
java.io.FileNotFoundException
- if the specified file was not found.public JWorkbook(java.io.File workbook, boolean staticView) throws java.io.FileNotFoundException, ExcelException
workbook
- is an Excel workbook file.staticView
- specifies whether the embedded workbook has active UI or not. If true
the workbook will be displayed in the static (not active) mode.
ExcelException
- if Excel cannot be run.
java.io.FileNotFoundException
- if the specified file was not found.Method Detail |
---|
public com.jniwrapper.win32.automation.OleMessageLoop getOleMessageLoop()
public JWorkbook.WorkbookContainer getContainer()
public Workbook getWorkbook()
Workbook
public void activate()
activate
in interface GenericWorkbook
public void deactivate()
public Window getWindow()
GenericWorkbook
getWindow
in interface GenericWorkbook
Window
public java.lang.String getAuthor()
GenericWorkbook
getAuthor
in interface GenericWorkbook
public void setAuthor(java.lang.String author)
GenericWorkbook
setAuthor
in interface GenericWorkbook
author
- is the workbook author name.public void removeWorksheet(Worksheet worksheet)
GenericWorkbook
removeWorksheet
in interface GenericWorkbook
worksheet
- specifies the worksheet to be removed.public void moveWorksheet(Worksheet worksheet, Worksheet after)
GenericWorkbook
moveWorksheet
in interface GenericWorkbook
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.public void copyWorksheet(Worksheet worksheet, Worksheet before, Worksheet after)
GenericWorkbook
copyWorksheet
in interface GenericWorkbook
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.public Application getApplication()
GenericWorkbook
getApplication
in interface GenericWorkbook
public void save() throws java.io.IOException
java.io.IOException
public void saveAs(java.io.File file, FileFormat fileFormat, boolean overwrite) throws java.io.IOException
java.io.IOException
public void saveCopyAs(java.io.File file) throws java.io.IOException
GenericWorkbook
saveCopyAs
in interface GenericWorkbook
file
- specifies the file name.
java.io.IOException
- if the workbook cannot be saved to the specified file.public void close()
java.lang.IllegalStateException
- if the component is in the preview mode.public void openWorkbook(java.io.File workbookFile) throws java.io.FileNotFoundException
workbookFile
- is an Excel workbook file to be opened.
java.lang.IllegalArgumentException
- if the target file is not an Excel workbookFile.
java.io.FileNotFoundException
- if the target file doesn't exist.
java.lang.IllegalStateException
- if the component is in the preview mode.public void newWorkbook()
java.lang.IllegalStateException
- if the component is in the preview mode.public void setPrintPreview(boolean value)
value
- if true
the workbook will be switched to
the print preview mode.public boolean isPrintPreview()
true
if the component is in the preview mode.
true
if the component is in the preview mode.public void showPrintDialog()
java.lang.IllegalStateException
- if the component is in the preview mode.public Worksheet addWorksheet(java.lang.String name) throws ExcelException
GenericWorkbook
addWorksheet
in interface GenericWorkbook
name
- is the name of a new worksheet.
ExcelException
- if a worksheet with such name already exists in the workbook.public Worksheet addWorksheet(Worksheet after, java.lang.String name) throws ExcelException
GenericWorkbook
addWorksheet
in interface GenericWorkbook
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.
ExcelException
- if a worksheet with such name already exists in the workbook.public Worksheet getWorksheet(java.lang.String name)
GenericWorkbook
null
.
getWorksheet
in interface GenericWorkbook
name
- is the name of the worksheet.
null
if such worksheet is not present.public java.util.List getWorksheets()
GenericWorkbook
Worksheet
class.
getWorksheets
in interface GenericWorkbook
public Worksheet getWorksheet(int index)
GenericWorkbook
getWorksheet
in interface GenericWorkbook
index
- is the index of the worksheet.
public Worksheet getActiveWorksheet()
GenericWorkbook
getActiveWorksheet
in interface GenericWorkbook
public void setEventHandler(WorkbookEventHandler eventHandler)
GenericWorkbook
setEventHandler
in interface GenericWorkbook
public void removeEventHandler()
GenericWorkbook
removeEventHandler
in interface GenericWorkbook
public void addWorkbookEventListener(WorkbookEventListener eventListener)
GenericWorkbook
addWorkbookEventListener
in interface GenericWorkbook
public void removeWorkbookEventListener(WorkbookEventListener eventListener)
GenericWorkbook
removeWorkbookEventListener
in interface GenericWorkbook
eventListener
- is the listener to be removed.public void setTitle(java.lang.String title)
GenericWorkbook
setTitle
in interface GenericWorkbook
title
- is a new title of the workbook.public java.lang.String getTitle()
getTitle
in interface GenericWorkbook
public java.io.File getFile()
null
.
getFile
in interface GenericWorkbook
public FileFormat getFileFormat()
GenericWorkbook
getFileFormat
in interface GenericWorkbook
public void print(int copies) throws javax.print.PrintException
GenericWorkbook
print
in interface GenericWorkbook
copies
- is the number of copies to be printed.
javax.print.PrintException
- if print problems occured.public void print(int firstSheet, int lastSheet, int copies) throws javax.print.PrintException
GenericWorkbook
print
in interface GenericWorkbook
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.
javax.print.PrintException
- if print problems occured.public int getWorksheetCount()
getWorksheetCount
in interface GenericWorkbook
public void setPassword(java.lang.String password)
setPassword
in interface GenericWorkbook
password
- stringpublic boolean hasPassword()
hasPassword
in interface GenericWorkbook
public void setWritePassword(java.lang.String password)
setWritePassword
in interface GenericWorkbook
password
- is a new write protection passwordpublic java.lang.String getWorkbookName()
getWorkbookName
in interface GenericWorkbook
public boolean isReadOnly()
isReadOnly
in interface GenericWorkbook
public boolean isSaved()
isSaved
in interface GenericWorkbook
public boolean isClosed()
isClosed
in interface GenericWorkbook
public boolean isActive()
public void addJWorkbookEventListener(JWorkbookEventListener eventListener)
eventListener
- for this JWorkbookJWorkbookEventListener
,
JWorkbookEventAdapter
public void removeJWorkbookEventListener(JWorkbookEventListener eventListener)
eventListener
- for this JWorkbookJWorkbookEventListener
,
JWorkbookEventAdapter
public void addPrintPreviewListener(PrintPreviewListener l)
public void removePrintPreviewListener(PrintPreviewListener l)
public void setStaticMode(boolean value)
value
- if true
the workbook is displayed in a static mode, otherwise in a UI active mode.public boolean isStaticMode()
true
if the workbook is displayed in a static mode and false
otherwise.
true
if the workbook is displayed in a static mode and false
otherwise.public boolean isWorkbookCreated()
public void notifyPrintPreviewStateChanged()
public void onPrintPreview()
public void onPrintPreviewExit()
protected void setContainer(JWorkbook.WorkbookContainer container)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |