Sponsored Content
Top Forums Shell Programming and Scripting Unable to create spreadsheet in cgi script Post 302829383 by scriptscript on Thursday 4th of July 2013 05:03:14 PM
Old 07-04-2013
Unable to create spreadsheet in cgi script

hi folks,

I am trying to download xlsx from cgi page in browser but not sure where I made a mistake.

the cgi script contains the code for creating xlsx and just by clicking on the image I should be able to

Code:
#!/usr/bin/perl -w
use Excel::Writer::XLSX;
use DBI;
use DBD::mysql;
use CGI;
use CGI qw(:standard);
use CGI::Carp qw ( fatalsToBrowser );

 $q=new CGI;


$report_year = $q->param('Field_year');
$report_month = $q->param('Field_month');
$report_year = $q->param('Field_year');
$string="$report_month"." "."$report_year"." "."Network Availability Report";

$report_name="Network_Availability_Report_".$report_month."_".$report_year.".xlsx";
   
my $workbook   = Excel::Writer::XLSX->new("$report_name");
my $worksheet  = $workbook->add_worksheet($report_month);


print "Content-type: text/html\n\n";
print '<html>';
print '<head>';
print '<title>Hello Word - First CGI Program</title>';
print '</head>';
print '<body>';
print "<h2>$report_month</h2>";
print "<h2>$report_year</h2>";
#print qq~<a href="http://25.209.200.143/$report_name"><img src="http://25.209.200.143/tcs/images/xlsx.png" width=40 height=40></a>~;
print '</body>';
print '</html>';

1;

If I click on the image then I need to open the spreadsheet.

I have managed to execute the same in windows and able to display it on windows.

Now I am deploying the code in unix but failed to display this cgi script.

Error

Code:
Can't call method "add_worksheet" on an undefined value at /srv/www/cgi-bin/gnsncc/temp_final_report.cgi line 20.

I made sure that all the scripts has 755 permissions.

I am executing the scripts from cgi-bin folder.


Could anyone please let me know what went wrong.

Regards,
J
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

CGI passing arrays/hashes to another CGI script

If I have a Perl CGI script (script01), which fills an array(s) with information and outputs a HTML page with a link to another CGI page (script02); is there anyway to pass the array(s) from "script01" to "script02" when the page visitor clicks the link? Hope that makes sense! :) (2 Replies)
Discussion started by: WIntellect
2 Replies

2. UNIX for Dummies Questions & Answers

unable to view the output through this cgi

#!/bin/env perl read(STDIN,$temp,$ENV{'CONTENT_LENGTH'}); @pairs=split(/&/,$temp); $DISPLAY1 = "/u/inarram111/dev/web/HNW/BNY/unsecure-html/myscript2.html"; $DATAFILE1 = "/u/inarram111/dev/web/HNW/BNY/unsecure-cgi-bin/datafile"; open (DATAFILE1, ">$DATAFILE1") || die " Error opening log file... (0 Replies)
Discussion started by: rishchand
0 Replies

3. Shell Programming and Scripting

create a new directory from cgi script

hello. i hav accepted name of directory from user through a form.now i need to create a directory under cgi-bin of that name.I am not able to do so.n help is required (12 Replies)
Discussion started by: raksha.s
12 Replies

4. Shell Programming and Scripting

problem for CGI create Cookie!!!!

Hi Everyone, I am facing the problem to create the cookie in CGI (bash script). Is it possible can create in cgi? or javascript better? Anyone got the sample to create the cookie in cgi(bash script)? Just the login will do ->> USERNAME and PASSWORD after create how to store into the... (2 Replies)
Discussion started by: ryanW
2 Replies

5. Shell Programming and Scripting

Help to create a Return Button using shell script CGI

Hello Guys, I would like to know how can I create a radio button on that its possible to return to the last page, using a ksh CGI shell script. Can someone help ? Thanks so much !!!:b: I tried this, but it is a javascript code ! <INPUT TYPE="button" VALUE="BACK" ... (2 Replies)
Discussion started by: robdcb
2 Replies

6. UNIX for Dummies Questions & Answers

create cgi-bin

Hello anyone, I'm a PHP programmer that, through work has to be a server administrator. We have a dedicated server at godaddy. I just found this forum but probably could have asked a thousand questions that I've already figured out. I tried finding anything online and would think this would... (0 Replies)
Discussion started by: Freddythunder
0 Replies

7. Programming

CGI Perl script to execute bash script- unable to create folder

Hi I have a bash script which takes parameters sh /tmp/gdg.sh -b BASE-NAME -n 1 -s /source/data -p /dest/data/archive -m ARC gdg.sh will scan the /source/data and will move the contents to /dest/data/archive after passing through some filters. Its working superb from bash I have... (0 Replies)
Discussion started by: rakeshkumar
0 Replies

8. Shell Programming and Scripting

Can't create file in CGI Script

Hi I have some simple script within the context of a cgi script that create a file to write to. If I run the script from the command line as root the file is created with no issue. However when I run the script from a web page with the apache account, it dies. The code lines are: sub... (3 Replies)
Discussion started by: larryjmoon
3 Replies

9. Shell Programming and Scripting

Perl CGI : unable to download the excel sheet from perl cgi page

Hi All, I have written an cgi perl script that displays an image(Excel image) and when clicked on that Image I need to download a excel sheet. I made sure that excel sheet exists in the folder with the given name but still I am not able to download the sheet. print "<center><table... (2 Replies)
Discussion started by: scriptscript
2 Replies

10. Shell Programming and Scripting

Perl script to create/write into spreadsheet

Hi, I need help in debug following script. can somebody help....!!! #!/usr/bin/perl -w use strict; use Spreadsheet::WriteExcel; # Create a new workbook called simple.xls and add a worksheet. my $workbook = Spreadsheet::WriteExcel->new('simple.xls'); my $worksheet =... (1 Reply)
Discussion started by: chettyravi
1 Replies
Excel::Writer::XLSX::Chart::Area(3pm)			User Contributed Perl Documentation		     Excel::Writer::XLSX::Chart::Area(3pm)

NAME
Area - A class for writing Excel Area charts. SYNOPSIS
To create a simple Excel file with a Area chart using Excel::Writer::XLSX: #!/usr/bin/perl use strict; use warnings; use Excel::Writer::XLSX; my $workbook = Excel::Writer::XLSX->new( 'chart.xlsx' ); my $worksheet = $workbook->add_worksheet(); my $chart = $workbook->add_chart( type => 'area' ); # Configure the chart. $chart->add_series( categories => '=Sheet1!$A$2:$A$7', values => '=Sheet1!$B$2:$B$7', ); # Add the worksheet data the chart refers to. my $data = [ [ 'Category', 2, 3, 4, 5, 6, 7 ], [ 'Value', 1, 4, 5, 2, 1, 5 ], ]; $worksheet->write( 'A1', $data ); __END__ DESCRIPTION
This module implements Area charts for Excel::Writer::XLSX. The chart object is created via the Workbook "add_chart()" method: my $chart = $workbook->add_chart( type => 'area' ); Once the object is created it can be configured via the following methods that are common to all chart classes: $chart->add_series(); $chart->set_x_axis(); $chart->set_y_axis(); $chart->set_title(); These methods are explained in detail in Excel::Writer::XLSX::Chart. Class specific methods or settings, if any, are explained below. Area Chart Methods There aren't currently any area chart specific methods. See the TODO section of Excel::Writer::XLSX::Chart. EXAMPLE
Here is a complete example that demonstrates most of the available features when creating a chart. #!/usr/bin/perl use strict; use warnings; use Excel::Writer::XLSX; my $workbook = Excel::Writer::XLSX->new( 'chart_area.xlsx' ); my $worksheet = $workbook->add_worksheet(); my $bold = $workbook->add_format( bold => 1 ); # Add the worksheet data that the charts will refer to. my $headings = [ 'Number', 'Batch 1', 'Batch 2' ]; my $data = [ [ 2, 3, 4, 5, 6, 7 ], [ 40, 40, 50, 30, 25, 50 ], [ 30, 25, 30, 10, 5, 10 ], ]; $worksheet->write( 'A1', $headings, $bold ); $worksheet->write( 'A2', $data ); # Create a new chart object. In this case an embedded chart. my $chart = $workbook->add_chart( type => 'area', embedded => 1 ); # Configure the first series. $chart->add_series( name => '=Sheet1!$B$1', categories => '=Sheet1!$A$2:$A$7', values => '=Sheet1!$B$2:$B$7', ); # Configure second series. Note alternative use of array ref to define # ranges: [ $sheetname, $row_start, $row_end, $col_start, $col_end ]. $chart->add_series( name => '=Sheet1!$C$1', categories => [ 'Sheet1', 1, 6, 0, 0 ], values => [ 'Sheet1', 1, 6, 2, 2 ], ); # Add a chart title and some axis labels. $chart->set_title ( name => 'Results of sample analysis' ); $chart->set_x_axis( name => 'Test number' ); $chart->set_y_axis( name => 'Sample length (mm)' ); # Set an Excel chart style. Blue colors with white outline and shadow. $chart->set_style( 11 ); # Insert the chart into the worksheet (with an offset). $worksheet->insert_chart( 'D2', $chart, 25, 10 ); __END__ AUTHOR
John McNamara jmcnamara@cpan.org COPYRIGHT
Copyright MM-MMXII, John McNamara. All Rights Reserved. This module is free software. It may be used, redistributed and/or modified under the same terms as Perl itself. perl v5.10.1 2012-04-02 Excel::Writer::XLSX::Chart::Area(3pm)
All times are GMT -4. The time now is 06:49 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy