This is my first post.
Would you like to store data in Excel and execute Python? Do you want to start Python from Excel when you repeat data change ⇔ execution?
There is a way to use VBA when I search the net, but I don't like it so I tried this method.
Those who have all of the following ・ I want to analyze the data stored in Excel with Python. ・ I want to use Excel as the front end ・ I don't want to use VBA ・ I am using Windows
Start bat using the Excel hyperlink. If you write a statement to start Python in the bat file, Python will work just by pressing the link from Excel.
Suppose you have an Excel file and a Python file you want to run, as shown below.
Create a bat file as shown below. The save location is the same as the above file. The first line is cd to "% ~ dp0". "% ~ Dp0" is a value that indicates the path where this bat file was saved. The second line is the Python startup statement.
Right-click on the cell you like in Excel and select "Link" to select the bat file you created earlier.
If you press this hyperlink, bat will open automatically and Python will start automatically. In Python, you should set pandas to read Excel data.
It was a trick, but I was able to achieve my goal without using VBA. Please use it if you like.
Recommended Posts