excel export

Discussion in 'Perl Misc' started by naren, Feb 10, 2004.

  1. naren

    naren Guest

    Hi,
    I am trying to export some data into excel through cgi script,
    I am using a standard example given in Spreadsheet::WriteExcel
    module,
    here is the code:

    --------------------------------------------------------
    #!/apps/bin/perl -w

    use strict;
    use Spreadsheet::WriteExcel;

    # Set the filename and send the content type
    my $filename ="cgitest.xls";

    print "Content-type: application/vnd.ms-excel\n";
    # The Content-Disposition will generate a prompt to save the file. If
    you want
    # to stream the file to the browser, comment out the following line.
    print "Content-Disposition: attachment; filename=$filename\n";
    print "\n";

    # Create a new workbook and add a worksheet. The special Perl
    filehandle - will
    # redirect the output to STDOUT
    #
    my $workbook = Spreadsheet::WriteExcel->new("-");
    my $worksheet = $workbook->add_worksheet();

    # Set the column width for column 1
    $worksheet->set_column(0, 0, 20);

    # Create a format
    my $format = $workbook->add_format();
    $format->set_bold();
    $format->set_size(15);
    $format->set_color('blue');

    # Write to the workbook
    $worksheet->write(0, 0, "Hi Excel!", $format);
    ----------------------------------------------------

    But the script is failing at $workbook->add_worksheet(),
    here is the error message:
    ---
    Can't locate object method "add_worksheet" via package
    "Spreadsheet::WriteExcel" (perhaps you forgot to load
    "Spreadsheet::WriteExcel"?) at /cgi-excel.pl line 19.
    ---

    I have checked the path, it should be getting the
    Spreadsheet::WriteExcel module, this error may be missleading??
    This code was working FINE till last week, but it has broken now;
    recently we have updated some of our other perl modules like IO, MIME
    etc,
    if Spreadsheet::WriteExcel module is using some of those libraries
    internally, is there a chance that it will be affected?? I assume it
    is not.

    Can any body any idea??

    thanks,
    Naren.
     
    naren, Feb 10, 2004
    #1
    1. Advertising

  2. naren

    Simon Taylor Guest

    Hello Naren,

    > I am trying to export some data into excel through cgi script,
    > I am using a standard example given in Spreadsheet::WriteExcel
    > module,
    > here is the code:
    >
    > --------------------------------------------------------
    > #!/apps/bin/perl -w
    >
    > use strict;
    > use Spreadsheet::WriteExcel;


    [snip]

    > my $workbook = Spreadsheet::WriteExcel->new("-");
    > my $worksheet = $workbook->add_worksheet();


    This should be:

    my $worksheet = $workbook->addworksheet();


    > my $format = $workbook->add_format();


    and that should be:

    my $format = $workbook->addformat();

    Happy hacking.

    Simon Taylor
    --
    Unisolve Pty Ltd - Melbourne, Australia
     
    Simon Taylor, Feb 11, 2004
    #2
    1. Advertising

  3. naren wrote:

    > But the script is failing at $workbook->add_worksheet(),
    > here is the error message:
    > ---
    > Can't locate object method "add_worksheet" via package
    > "Spreadsheet::WriteExcel" (perhaps you forgot to load
    > "Spreadsheet::WriteExcel"?) at /cgi-excel.pl line 19.


    Hi,

    The method names add_worksheet() and add_format() were added in
    version 0.41 of the Spreadsheet::WriteExcel. From the changelog:

    0.41 April 24 2003 - Minor

    ! Renamed addworksheet() and addformat() to add_worksheet()
    and add_format() for consistency with other method names.
    Older names are supported but deprecated.


    If you have an older version use addworksheet() and addformat()
    instead.

    John.
    --
     
    John McNamara, Feb 11, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?RGF2aWQgVmFsbGU=?=

    Invalid export DLL or export format

    =?Utf-8?B?RGF2aWQgVmFsbGU=?=, Oct 29, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    3,625
    =?Utf-8?B?RGF2aWQgVmFsbGU=?=
    Oct 29, 2003
  2. =?Utf-8?B?U3JpZGhhcg==?=

    using Microsoft Excel image for Export to Excel button

    =?Utf-8?B?U3JpZGhhcg==?=, Dec 9, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    3,115
    =?Utf-8?B?U3JpZGhhcg==?=
    Dec 9, 2005
  3. =?Utf-8?B?SGVtYW50IFNpcGFoaW1hbGFuaQ==?=

    Export to Excel (Default File Type - Excel)

    =?Utf-8?B?SGVtYW50IFNpcGFoaW1hbGFuaQ==?=, Apr 24, 2006, in forum: ASP .Net
    Replies:
    15
    Views:
    17,534
    syed hassan
    May 21, 2009
  4. Grey
    Replies:
    4
    Views:
    1,997
    Mark Rae [MVP]
    Oct 17, 2007
  5. Maarten Porters
    Replies:
    1
    Views:
    432
    Florian Gilcher
    Jul 28, 2008
Loading...

Share This Page