Releases: ericremoreynolds/excelpython
ExcelPython v2.0.9
New functionality to use installation information from the Windows registry. This allows you, for example, to instruct ExcelPython to use the default Python 2 installation even if Python 3 takes precedence according to the system path.
- New macros are available in
xlpython.cfg
providing the folder of each Python version installed and registered as default, as contained in the Windows registry. Further information is available in the docs. - It is now possibile to include a trailing slash within macro parentheses, for example like so:
$(?Registry:Python2Folder\)python.exe
. This means that if the macro is not defined the string will simply resolve topython.exe
and not\python.exe
as it would were the slash outside the macro parentheses. - Small bug fix related to reloading config files.
ExcelPython v2.0.8
Minor changes
- Now compatible with xlwings v0.3.0 and no longer compatible with previous versions
- DLLs are now statically linked against C++ runtime to avoid problems like #36
- Installer now installs only for current user and no longer requires admin rights
ExcelPython v2.0.7
This release introduces a minor change regarding the assumptions ExcelPython makes about the dimensionality of an input argument when it is not explicitly specified.
- Previous behavior: when the dimensionality of an argument is not explicitly specified using the
@xlarg
decorator, it is passed to Python as- a scalar if the input array is 1-by-1
- a 2-dimensional tuple otherwise
- New behavior: when the dimensionality of an argument is not explicitly specified using the
@xlarg
decorator, it is passed to Python as- a scalar if the input array is 1-by-1
- a 1-dimensional tuple if the input array is 1-by-n or n-by-1
- a 2-dimensional tuple otherwise
If you want to force ExcelPython to behave like previous releases, decorate the function with @xlarg("argname", dims=-2)
.
If the dimensionality of the argument is explicitly specified by decorating the function with @xlargs
with dims
equal to 0, 1 or 2, the behavior is the same as in previous releases.
ExcelPython v2.0.6
-
Added variable arguments length UDFs
@xlfunc def my_udf(x, *y): ...
All attributes apply to each single argument passed, for example
@xlfunc @xlarg("y", dims=2) def my_udf(x, *y): ...
will ensure that each element of
y
is 2-dimensional, noty
itself. -
VBA7/64-bit
PtrSafe
bug fix inxlpython.bas
ExcelPython v2.0.5
-
Bug fix for Python 3.x: now using
items
instead ofiteritems
for iterating over dictionaries, as the latter is not supported in 3.x. -
UDF arguments can be marshaled as
"list"
so that rather than arriving as tuples or tuples of tuples, they arrive as lists or lists of lists:# the function will return something like "[[1.0, 2.0], [3.0, 4.0]]" # depending on the input range. @xlfunc @xlarg("x", "list", dims=2) def list_function_2d(x): return str(x) # the function will return something like "[1.0, 2.0, 3.0]" # depending on the input range. @xlfunc @xlarg("x", "list", dims=1) def list_function_1d(x): return str(x)
It is recommended to always use the
dims
argument to specify the dimensionality, as single-cell values will still be marshaled as scalars even if"list"
is specified. Note that the implementation is not necessarily as efficient as it could be, it is provided just as convenient functionality. -
Now using
Application.PathSeparator
to calculate paths in the add-in, even though it shouldn't make any difference on any machine, for now. -
Fixed a bug on VBA7 (Excel 2010 on 64 bit systems) to do with missing
PtrSafe
keyword.
ExcelPython v2.0.4
- Now interacts smoothly with xlwings! Writing macros is even easier:
from xlpython import *
from xlwings import *
@xlsub(xlwings=True)
def mymacro():
Range("A1").value = [ 1, 2, 3 ]
- Fixed some compatibility issues with Python 3.x
ExcelPython v2.0.3
Some minor changes
- Added the
$(WorkbookDir)
macro for use inxlpython.cfg
- Added
@xlsub
decorator for defining user-defined subprocedures (as opposed to functions) - Added
vba
keyword argument in@xlarg
decorator, enabling you to hard-code argument values to a VBA expression evaluated at runtime - very useful for passing objects likeApplication
orThisWorkbook
to the Python function - COM objects are automatically wrapped using
win32com.client.Dispatch
when passed to Python so that they can be used dynamically without extra code.
ExcelPython v2.0.2
Lots of work on the add-in plus a few bug fixes and improvements to the runtime
- Documentation for existing and new add-in features will follow
- Python process is automatically killed if Excel dies
- Python tracebacks in error messages are inverted so that they are easier to read in Excel
- Added
xlpython_v1back.bas
which provides partial backwards compatibility with v1 if desired (just need to import it into the VBA project), this feature is provided as is however and no promises are made as to its proper functioning right now Py.Module
by default no longer automatically reloads the module unless explicitly requested.Py.AddPath
is deprecated.
ExcelPython v2.0.1
ExcelPython becomes an Excel add-in!
- To use this release unzip it somewhere and open up
xlpython.xlam
- The smiley face button now does automatically the setup steps described in the docs (folder is now called
xlpython
). - The other button creates VBA wrapper functions for the functions contained in the Python script with the same name as your workbook. Here's an example
# Book1.py
from xlpython import xlfunc
@xlfunc
def DoubleSum(x, y):
"""Returns twice the sum of the two arguments"""
return 2 * (x + y)
Click the 'Import Python UDFs' button and you should then be able to use the function in cell formulas.
ExcelPython v2.0.0
ExcelPython v2 is a major rewrite of ExcelPython. Whereas the old version was based on loading the Python runtime into the Excel process via PythonXX.dll, now Python is run out-of-process. This has a few advantages:
- any version of Python is immediately supported (as long as PyWin32 is installed) - and you can mix 32/64-bit Excel/Python.
- the Python runtime behaves exactly as it does when run from the command prompt
- no more DLL not found issues
- you can target a specific version of Python very easily and configure the execution environment precisely (e.g. path, environment variables, etc.) enabling you to embed a portable copy of Python in your project and ship it with your workbooks in a zip file.
ExcelPython v2 is designed to be portable in the sense that no installation, registration or admin rights are required to use it - just unzip it into the folder containing your workbooks, import the xlpython.bas
VBA source file and you're set!
It should (hopefully) all work out of the box without hassle! See the readme for instructions on how to get started.