xlwings is an open-source Python package that connects Excel with Python on Windows and Mac. It allows for interactive use from IPython Notebooks or any other Python environment but also allows to run Python code from Excel as replacement for VBA macros.
The talk will give an overview of the current Excel/Python landscape, show the characteristics of the xlwings package and include a live demo to show how easy the usage is. The demo will also include examples of tasks that would otherwise be difficult to do with Excel only as well as more real world tools built with Python where Excel merely acts as a user interface/frontend.
1. O P E N
D A T A
S C I E N C E
C O N F E R E N C E_
BOSTON 2015
@opendatasci
xlwings Felix Zumstein
2. About me
• Startup (2014, Zurich):
– Mainly Python for Finance
– Web based trading solutions
(Interactive Brokers)
– Lots of Excel
– Open-source: xlwings/ExcelPython
• Previously: 9yrs in Banking /Asset Mgmt
• Background in Finance & Economics
2
10. (5) Works back and forth
10
>>>
wb
=
Workbook()
>>>
Range("A1").value
=
my_variable
Sub
MyFunction()
RunPython
("import
mymodule;mymodule.myfunction()")
End
Sub
11. (6) ExcelPython for UDFs (Windows only)
11
from
xlpython
import
xlfunc
import
numpy
as
np
@xlfunc
def
matrix_mult(x,
y):
x
=
np.atleast_2d(np.array(x))
y
=
np.atleast_2d(np.array(y))
return
x.dot(y)
{=matrix_mult(A1:B2,D1:E2)}
Access from Excel via Array Formula:
Write User Defined Functions in Python:
13. What’s next?
• Add-in
• Full integration of xlwings/ExcelPython
• Add more features: matplotlib etc.
• Someday…
– Google Sheets
– LibreOffice/OpenOffice
13
14. julia>
using
PyCall
julia>
@pyimport
xlwings
as
xw
julia>
xw.Workbook()
julia>
xw.Range("A1",
asarray=true)[:table][:value]
Use xlwings from Julia
14
>>>
from
xlwings
import
Workbook,
Range
>>>
wb
=
Workbook()
>>>
Range("A1",
asarray=True).table.value