Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can CGI open Excel application Locally

Status
Not open for further replies.

dhsu

Programmer
Sep 16, 2002
2
US
Hi,
Can someone help me with this situation:
I have a web application that queries data. Once the data is retrieved, I want to dump it into excel on the local PC not the server side. When I tried using something like this:

use Spreadsheet::WriteExcel;
my $r = new cgi;
# print "Content-type: application/vnd.ms-excel\n\n";
# Create a new workbook called simple.xls and add a worksheet
my $workbook = Spreadsheet::WriteExcel->new("simple.xls");
my $worksheet = $workbook->addworksheet();

this .xls is saved on the server. Can I save the file locally?
Thanks.
 
For security reasons the original idea of HTML did not include the server's ability to write to the browser's filespace. You can do it with java if the user has sufficiently lax security settings or you can serve the document as normal and ask the user to save it. "As soon as we started programming, we found to our surprise that it wasn't as
easy to get programs right as we had thought. Debugging had to be discovered.
I can remember the exact instant when I realized that a large part of my life
from then on was going to be spent in finding mistakes in my own programs."
--Maurice Wilk
 
This sounds like a good place to use a web service to get the data off the server you want and use it locally.

Here is a simple example:

#module containing a subroutine you want to access
package Hello;
sub sayHello {
shift; #This removes the "class" name off the object
return "Hello " . shift;
}
1;

#now create a web service to get your data
#!/usr/bin/perl -w
#webservice.cgi - webservice SOAP handler
use SOAP::Transport::HTTP;
SOAP::Transport::HTTP::CGI
->dispatch_to('Hello::(?:sayHello)')
->handle
;

#now make a client application for access to webserver from Desktop
#!/usr/bin/perl -w
#ws_client.pl - Hello client
use SOAP::Lite;
my $name = shift;
print "\\Calling SOAP Server to say hello\n\n";
print "The SOAP Server says: ";
print SOAP::Lite
->uri('urn:Example1')
->proxy('->sayHello($name)
->result . "\n\n";

Install the webservice.cgi on your server
Install the Hello.pm and make sure @INC has the path to it
At the command line type
% perl ws_client.pl James

Your client should reach accross the internet for the subroutine sayHello and display

Calling the SOAP server to say Hello
The SOAP Server says: Hello James

HTH
 
Thanks all for the response.
I've decided just keep the file on the server and create a link to download it. I'll probably then create an automated scripted to purge the old files on the server.

 
Look into the LWP module to automate the download process if you want. You can literally FTP the info right to your program and do what you will with it.

Check

for the module info, infact you can just use 'perldoc lwpcook' on the command line.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top