Re: [web2py] export data to OOO and Excel
Another solution : You can simply link data to a Excel/OOo spreadsheet. >From web2Py, you only need a view with a HTML table of your data. In Excel or OOo you link your spreadsheet to your URL. Advantages : - you don't have to build your Excel file in w2p (no extra module) - you can link your data with different worksheets - you can refresh data in Excel/OOo (manual or automatic) - layout and formatting is preserved at each refresh 2011/7/20 Vineet : > I was looking for a library to export data to OpenOffice & Excel. > I found 2 such open source projects. > > For OOO --- > http://ooolib.sourceforge.net/ > > For Excel --- > http://www.python-excel.org/ > > What I intend to do is, keep the classes in web2py folder, import the > classes in controller, then parse the result fetched from MySQL and > export the data to OOO or Excel. > > Reasons as to why I am posting it here are-- > > 1] Whether anybody has tried these and knows if these are mostly bug- > free (may not be 100%) > 2] Whether anybody knows any other (better suited, may be) projects > like these (considering integration into w2p, feature-rich, tested, > etc.) > 3] To share my findings with the list (might be useful to someone > new). > > Cheers > :-) >
Re: [web2py] export data to OOO and Excel
On Thu, Jul 21, 2011 at 3:40 PM, Dave wrote: > This works great, but when i download the file it is missing the extension. > Is there an easy way to add '.xls' to the file name? > > Thanks, > Dave Hi Dave, how do you download the file? This method is an action in one controller, ie: http://127.0.0.1:8000/myapp/printer/excel_report and the file is downloaded as XLS. Joaco.
Re: [web2py] export data to OOO and Excel
This works great, but when i download the file it is missing the extension. Is there an easy way to add '.xls' to the file name? Thanks, Dave
Re: [web2py] export data to OOO and Excel
On Wed, Jul 20, 2011 at 5:45 AM, Vineet wrote: > I was looking for a library to export data to OpenOffice & Excel. > I found 2 such open source projects. > > For OOO --- > http://ooolib.sourceforge.net/ > > For Excel --- > http://www.python-excel.org/ > > What I intend to do is, keep the classes in web2py folder, import the > classes in controller, then parse the result fetched from MySQL and > export the data to OOO or Excel. > > Reasons as to why I am posting it here are-- > > 1] Whether anybody has tried these and knows if these are mostly bug- > free (may not be 100%) > 2] Whether anybody knows any other (better suited, may be) projects > like these (considering integration into w2p, feature-rich, tested, > etc.) > 3] To share my findings with the list (might be useful to someone > new). > > Cheers > :-) Hi Vineet, I used xlwt for a non-production site and worked fine for me (just a very simple report with a small formatting). This is a quick example: def excel_report(): from datetime import datetime import xlwt tmpfilename=os.path.join(request.folder,'private',str(uuid4())) font0 = xlwt.Font() font0.name = 'Arial' font0.bold = True style0 = xlwt.XFStyle() style0.font = font0 style1 = xlwt.XFStyle() style1.num_format_str = 'DD--' wb = xlwt.Workbook() ws = wb.add_sheet('Sample report') ws.write(0, 0, 'Text here', style0) ws.write(0, 6, 'More text here', style0) ws.write(0, 7, datetime.now(), style1) wb.save(tmpfilename) data = open(tmpfilename,"rb").read() os.unlink(tmpfilename) response.headers['Content-Type']='application/vnd.ms-excel' return data Hope it helps you. Joaco.
[web2py] export data to OOO and Excel
I was looking for a library to export data to OpenOffice & Excel. I found 2 such open source projects. For OOO --- http://ooolib.sourceforge.net/ For Excel --- http://www.python-excel.org/ What I intend to do is, keep the classes in web2py folder, import the classes in controller, then parse the result fetched from MySQL and export the data to OOO or Excel. Reasons as to why I am posting it here are-- 1] Whether anybody has tried these and knows if these are mostly bug- free (may not be 100%) 2] Whether anybody knows any other (better suited, may be) projects like these (considering integration into w2p, feature-rich, tested, etc.) 3] To share my findings with the list (might be useful to someone new). Cheers :-)