Greetings folks, I have done this so much simpler. Although it may or may not work in your particular environment, it is worth a try: Get zope to display table and via browser's pulldown menu save it (file->save page as) giving a name with .xls extension. That's it. The particular environment I use: mozilla, win2000. The rest hardly matters. Tena Sakai (tena.sakai.b@bayer.com) "Meilicke, Scott" <scott.meilicke@i To: 'Micheál Healy' <michael.healy@engitech.ie>, "Zope@Zope.Org" ntp.com> <zope@zope.org> Sent by: cc: zope-admin@zope.o Subject: RE: [Zope] Zope and Excel rg 01/08/2003 09:38 AM I have done this the other way around (excel -> zope) via external methods and COM on a windows platform. Scott -----Original Message----- From: Micheál Healy [mailto:michael.healy@engitech.ie] Sent: Tuesday, January 07, 2003 2:55 AM To: Zope@Zope.Org Subject: [Zope] Zope and Excel Hi all, I want to create a report or spreadsheet in MS Excel and populate it from Zope. Can anyone tell me if there is a product for Zope that will help, or should I just look for a generic python script that does it and use that. If anyone has a working example, I'd appreciate code samples and anything else you can provide. TIA, Micheál _______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev ) The information contained in this email message may be privileged and is confidential information intended only for the use of the recipient or any employee or agent responsible for delivering it to the intended recipient. Any unauthorized use, distribution or copying of this information is strictly prohibited and may be unlawful. If you have received this communication in error, please notify the sender immediately and destroy the original message and all attachments from your electronic files. _______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
This is a repost of the solution I came up with months ago: There was a thread here a while ago about trying to get decent reports into Excel. I posted a bit about generating CSV files and setting the right headers. Alas, there are a host of problems with this, including different behaviors bewteen browsers and Excel versions. I realized one thing Excel does do well is import HTML. So I propose this odd solution for people who need to export to excel (it works for me with both mozilla and IE6, exporting to excel 2k): Start your export file with '<html><body><table>'. List your rows as '<tr><td>xxx</td><td>xxx</td></tr>' And wrap up with </table></body></html>' In other words, just send a basic HTML document with a table in it. Then change your headers as follows: response.setHeader('Content-type', 'application/vnd.ms-excel') response.setHeader('Content-Length', len(result_str)) response.setHeader('Content-Disposition', 'attachment;filename=report.xls') This icky solution works because: 1) Excel recognizes HTML quite well no matter what the suffix. 2) Mozilla obeys the content-type header and launches excel. 3) IE ignores content-type and instead fixates on the filename suffix. The nice benefits are, of course, full HTML formatting and a reduced likelihood of needing to escape your data cells' content. The drawback is this is excel specific and your data is not in the common CSV format. There is also now a need to format your data since excel seems to remove all formatting (including cell borders) when importing an unadorned table.
participants (2)
-
Charlie Reiman -
Tena Sakai