With this method, you control Excel spreadsheets via Python scripts, similar to the
approach presented in the previous section.
User-defined functions
Using this approach, you expose your own Python functions to Excel in such a way
that they can be called from within Excel.
Both methods need an installation of the DataNitro solution to work — i.e., you cannot
distribute something that you have worked on to somebody else who does not have the
DataNitro solution installed.
Scripting with DataNitro
Open the previously generated spreadsheet file workbook.xlsx in Excel. We want to work
with DataNitro and this particular file. When you then click on the Python Shell symbol
in the DataNitro ribbon, your screen should look like Figure 12-5.
Figure 12-5. Screenshot of Excel with DataNitro IPython shell
A simple session could then look like the following:
In [ 1 ]: Cell(“B1”)
Out[ 1 ]: B1
In [ 2 ]: Cell(“B1”).value
Out[ 2 ]: 9
In [ 3 ]: Cell(“B1”).value = ‘Excel with Python’
# this immediately changes the (displayed) value
# in the spreadsheet