Hello, I am very new to web2py. This is my goal: I want to open an existing Excel file and have a user submit data into a form on a webpage. The form is connected to specific cells within the existing Excel file. When they submit the form the data is saved into a new file, traced to that specific user. So the existing Excel file is never altered with the new values it is just used as a template. I have stumbled upon "OpenPyXL", I am not sure if I am able to use this within web2py and how I would go about incorporating it, or if there is a simpler way, or if what I want to do is even possible within web2py. The researching I have done it seems as though things similar to what I want to do are possible.
So far I have an excel spreadsheet which has a few populated cells, correlating to questions asked in the web form. I keep running into errors when I go from the form page to the next page.. It will generate the new excel file, but it will not place the submitted form value into the cell. Here is my code: My model: (I will add input validators later) db = DAL('sqlite://webform.sqlite') db.define_table('excelform', Field('last_name', 'string'), Field('first_name', 'string'), Field('age', 'string'), Field('location', 'string') ) My controller : def excelform(): update = db.excelform(request.args(0)) form = SQLFORM(db.excelform, update) if form.accepts(request,session): response.flash = 'Thanks! The form has been submitted.' session.vars=form.vars redirect(URL('about')) elif form.errors: response.flash = 'Please correct errors.' else: response.flash = 'Try again, no empty values.' return dict(form=form) def about(): import sys form = SQLFORM(db.excelform) from openpyxl import load_workbook wb = load_workbook(filename='filepath/excel.xlsx') sheet_ranges = wb['Sheet1'] sheet_ranges['C4'] = form.vars.last_name wb.save(filename='/filepath/excel2.xlsx') message = "Check new file" return dict(message=message) I will appreciate any advice! Please and thank you. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.