use CGI (); # <<--update
print CGI::header(-type => 'application/vnd.ms-excel');
| [reply] [d/l] |
As a side note, please consult Q257757, which gives some good reasons to not run Office programs behind the scenes on a non-interactive session, like a CGI script. It points you at the OWC (Office Web Componants) which can be used for similar effect. Also consider Spreadsheet::WriteExcel, which will let you produce Excel files without the bloat of Excel itself.
I do a lot of Excel automation in interactive mode, but doing so in a CGI is risky and not advisable.
| [reply] |
Thankyou very much for your time and advise.
This seems to work nicely. Using the code you provided, do i simply just use a series of 'print' commands to generate output rather than using Win::OLE code such as $worksheet->Cells(5,1)->{Value} = "Dunedin 9001";
This embeeds excel into my application (great), but how can i allow my client to print the page contents? I know good old Ctrl + P works fine, but is not really feasible. Can i also embeed the Main menu of excel into my page? Thankyou again for your help. I would be lost without you guys.
Digger
Also when i run this script from a button on a previous page, it pops up a dialog box asking to open or save. Can i avoid this unwanted step
| [reply] |
We're going to need a little more about how you have your webserver set up, what you're really trying to do, and how you expect your users to do it.
When I output an Excel version of reports that users run on my webapp, I just print it out to the browser with the appropriate Content-Type header and the browser does the right thing. At that point, the user is welcome to look at it, save it, or print it ... as they see fit.
------
We are the carpenters and bricklayers of the Information Age.
Then there are Damian modules.... *sigh* ... that's not about being less-lazy -- that's about being on some really good drugs -- you know, there is no spoon. - flyingmoose
I shouldn't have to say this, but any code, unless otherwise stated, is untested
| [reply] |
The project involves a Microsoft SQL Database and a perl cgi interface, on a Win XP machine, running the apache webserver. I learned about avaliable GUI's for perl, (Tk etc) as this is a system run on a single machine, but did not have the time to learn (Is it worth learning for applications?). I am reading values from the database and now I am wanting to print this information. I looked at Javascripts but found they added unwanted text to my printed page. This is why Win::OLE plus it adds the ability to save this information as an xls document. I have read information that apache does not let external programs run, and this is why my scripts only run when ran from a command prompt. Thankyou for the code to embeed excel into my application. Just now want to be able to allow printing from this page (Ctrl + P) and save. | [reply] |