Quantitative Analysis
Parallel Processing
Numerical Analysis
C++ Multithreading
Python for Excel
Python Utilities
Services
Author

I. Motivation and design (PFE).
II. Installation of the Python for Excel.
III. Tutorial introduction into the Python for Excel.
IV. PFE Programmer's reference.
1. Direct access to Excel API.
2. Lower level access to Excel API.
3. Event trapping (PFE).
A. OnNewWorkbook property (ExcelListener).
B. OnSheetActivate property (ExcelListener).
C. OnSheetBeforeDoubleClick property (ExcelListener).
D. OnSheetBeforeRightClick property (ExcelListener).
E. OnSheetCalculate property (ExcelListener).
F. OnSheetChange property (ExcelListener).
G. OnSheetDeactivate property (ExcelListener).
H. OnSheetFollowHyperlink property (ExcelListener).
I. OnSheetSelectionChange property (ExcelListener).
J. OnWindowActivate property (ExcelListener).
K. OnWindowDeactivate property (ExcelListener).
L. OnWindowResize property (ExcelListener).
M. OnWorkbookActivate property (ExcelListener).
N. OnWorkbookBeforeClose property (ExcelListener).
O. OnWorkbookBeforePrint property (ExcelListener).
P. OnWorkbookBeforeSave property (ExcelListener).
Q. OnWorkbookDeactivate property (ExcelListener).
R. OnWorkbookNewSheet property (ExcelListener).
S. OnWorkbookOpen property (ExcelListener).
4. Configuration files (PFE).
Index. Contents.

Event trapping (PFE).


he facilities for the event trapping are provided by the predefined object ExcelListener. Each of the On<Event> properties has the methods "bind" and "bindTo" for assigning a callable object intended to be called if the event is fired. The method "signature" returns a description of the signature that the callable object is expected to have.


Figure

The method "bind" assigns a general handler to be run every time when an event of the particular type is fired.

The method "bindTo" provides selective handler assignment. Its first argument takes either string, unicode or a PFE object. Such argument selects the source of the event to be bound to the event handler. When an event is fired the ExcelListener would obtain the source of event (workbook or worksheet). Such source always has a name. The ExcelListener would run all handlers assigned to the event by "bind". It would also run only those handlers assigned by "bindTo" to an object of the same name.

The methods "unbind" and "unbindTo" remove the event handlers.

The intended place of use for the ExcelListener is a pfe-script. See the section on configuration files for information on pfe-scripts. The ExcelListener may also be used in the ControlShell.

IMPORTANT!!!! The ExcelListener does not do any exception catching for the event handlers. It executes the handlers one-by-one and allows an exception to propagate if thrown. The user may replace this behavior by modifying the Python implementation of the ExcelListener in the file vbaEvents.py located in the PythonForExcel installation directory. The exact place for such modification if the __call__ method of the _Binder class. This method is also the place where the programmer may study and/or modify the order of execution for the event handlers.

IMPORTANT!!!! The "OnWorkbookOpen" handlers should not contain calls to "Activate" method.




A. OnNewWorkbook property (ExcelListener).
B. OnSheetActivate property (ExcelListener).
C. OnSheetBeforeDoubleClick property (ExcelListener).
D. OnSheetBeforeRightClick property (ExcelListener).
E. OnSheetCalculate property (ExcelListener).
F. OnSheetChange property (ExcelListener).
G. OnSheetDeactivate property (ExcelListener).
H. OnSheetFollowHyperlink property (ExcelListener).
I. OnSheetSelectionChange property (ExcelListener).
J. OnWindowActivate property (ExcelListener).
K. OnWindowDeactivate property (ExcelListener).
L. OnWindowResize property (ExcelListener).
M. OnWorkbookActivate property (ExcelListener).
N. OnWorkbookBeforeClose property (ExcelListener).
O. OnWorkbookBeforePrint property (ExcelListener).
P. OnWorkbookBeforeSave property (ExcelListener).
Q. OnWorkbookDeactivate property (ExcelListener).
R. OnWorkbookNewSheet property (ExcelListener).
S. OnWorkbookOpen property (ExcelListener).

Index. Contents.


















Copyright 2007