Excel Python API

Viewed 39284

Does anyone know of a way of accessing MS Excel from Python? Specifically I am looking to create new sheets and fill them with data, including formulae.

Preferably I would like to do this on Linux if possible, but can do it from in a VM if there is no other way.

6 Answers

Its actually very simple. You can actually run anything from any program. Just see a way to reach command prompt from that program. In case of Excel, create a user defined function by pressing Alt+F11 and paste the following code.

Function call_cmd()
Shell "CMD /C Notepad", vbNormalFocus
End Function

Now press ctrl+s and go back to Excel, select a cell and run the function =call_cmd(). Here I ran Notepad. In the same way, you can see where python.exe is installed and run it. If you want to pass any inputs to python, then save the cells as file in local directory as csv file and read them in python using os.system().

Related