beginner_perl has asked for the wisdom of the Perl Monks concerning the following question:
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: export a table to excel
by jmcnamara (Monsignor) on Feb 26, 2002 at 17:52 UTC | |
You could try the Spreadsheet::WriteExcel module. The following is a simple CGI example:
There is also the Spreadsheet::WriteExcel::FromDB module which allows you to create Excel files directly from a DB query. You will find some other suggestions about how to create Excel files here.
--
| [reply] [d/l] |
|
Re: export a table to excel
by strat (Canon) on Feb 26, 2002 at 16:57 UTC | |
If it it a Win32-System, you can do so with Win32::ODBC or DBI and DBD::ODBC very easily. Just access Excel like a ODBC-Database, and use the single sheets like tables. Just take care that the Sheetname plus a $ at the end is the tablename. Or you could use Win32::OLE (have a look at the activestate perl-WinFaq). This has got more overhead, but if you want to format cells or build and execute makros, this might be the only way how it works. There are also Modules like Excel::Spreadsheet or the like, but I haven't tried them yet.
Best regards, | [reply] |
by Caillte (Friar) on Feb 26, 2002 at 17:05 UTC | |
When I had thsi problem on a linux system I used DBD::CSV to create a tab-seperated database and then used $cgi->redirect to change to it. Systems with Excel installed will treat files with a .csv extension as spreadsheets and convert them to Excel format when loading. The only problem with this is it will only transmit data, no fancy formatting ;) This page is intentionally left justified. | [reply] |
by lachoy (Parson) on Feb 26, 2002 at 17:28 UTC | |
Actually, you can really ensure the browser will send it to Excel by sending a content type of application/vnd.ms-excel, even for tab-delimited files. This has worked reliably for me across three versions of Excel. Chris | [reply] |
|
Re: export a table to excel
by dragonchild (Archbishop) on Feb 26, 2002 at 17:01 UTC | |
------ Don't go borrowing trouble. For programmers, this means Worry only about what you need to implement. | [reply] |
by jmcnamara (Monsignor) on Feb 26, 2002 at 17:58 UTC | |
For anyone interested in adopting a similar scheme the Excel XML and HTML file specifications are available here.
--
| [reply] |
|
Re: export a table to excel
by strat (Canon) on Feb 27, 2002 at 12:16 UTC | |
It's rather quick and a little dirty, but maybe it could give you some hints for using or not using Win32::OLE :-)
Best regards, | [reply] [d/l] |