Jun-24-2019, 05:45 AM
Hello,
I have made an HTML form and need to get the data that a user inputs into an excel sheet.
Looking around, i found that it could be possible with cgi.
I installed XAMPP and modified the httpd.conf file accordingly.
When i run a test.py file which outputs to the browser, it works.
But, when i try to send data from my form to the program (and i want to use openpyxl to then put it in excel sheet), the program doesnt run.
Instead, it prints the code from the .py file in the browser.
I've been at this for sometime now..i uninstalled and re-installed XAMMP thinking i might have made some bad changes somewhere, but no success.
It is a fairly lengthy form, which uses text fields, textareas, date, radio buttons and drop down menus.
This is the line from the html file where i specify the .py file to run.
This is the code that i want to run when i hit the submit button.
Any help will be highly appreciated.
Thanks!
I have made an HTML form and need to get the data that a user inputs into an excel sheet.
Looking around, i found that it could be possible with cgi.
I installed XAMPP and modified the httpd.conf file accordingly.
When i run a test.py file which outputs to the browser, it works.
But, when i try to send data from my form to the program (and i want to use openpyxl to then put it in excel sheet), the program doesnt run.
Instead, it prints the code from the .py file in the browser.
I've been at this for sometime now..i uninstalled and re-installed XAMMP thinking i might have made some bad changes somewhere, but no success.
It is a fairly lengthy form, which uses text fields, textareas, date, radio buttons and drop down menus.
This is the line from the html file where i specify the .py file to run.
<form name='History' action='file:///C:/xampp/cgi-bin/test.py' method='POST'>
This is the code that i want to run when i hit the submit button.
#!C:\Users\Daucus\AppData\Local\Programs\Python\Python37-32\python.exe import cgi, openpyxl form = cgi.FieldStorage() PatientID = form.getvalue('pid') wb = openpyxl.load_workbook('Book1.xlsx') sheet = wb['Sheet1'] sheet.cell(1,1).value = PatientID wb.save('Book1.xlsx')But it just prints this same thing as output.
Any help will be highly appreciated.
Thanks!