Excel sheet creation using perl

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rahatekarabhijeet
    New Member
    • Jan 2007
    • 55

    Excel sheet creation using perl

    I want to create excel sheet using perl, i had installed all the necessary modules from CPAN.

    The perl program i taken from CPAN itself it is given below,
    Code:
    #!/usr/bin/perl -w
    use warnings;
    use strict;
    use Excel::Template;
    # Create the Excel template
    my $template = Excel::Template->new(
    	filename => 'test.xml',
    );
    # Add a few parameters
    $template->param(
    	HOME => $ENV{HOME},
    	PATH => $ENV{PATH},
    );
    $template->write_file('test.xls');
    and test.xml is
    Code:
    <workbook>
    <worksheet name="tester">
    <cell text="$HOME" />
    <cell text="$PATH" />
    </worksheet>
    </workbook>
    test.xls file is getting created but when i tries to open it i am getting following error,
    Error loading document file filename
    Incorrect file format

    So help me for overcoming on this problem.
    Last edited by miller; Mar 1 '07, 04:47 PM. Reason: Code tag
  • miller
    Recognized Expert Top Contributor
    • Oct 2006
    • 1086

    #2
    I do not know why Excel::Template is not working for you as I have no experience with it. I suggest that you use Spreadsheet::Wr iteExcel instead, as it more commonly used and has a lot more features:

    cpan Spreadsheet::Wr iteExcel

    - M

    Comment

    • rahatekarabhijeet
      New Member
      • Jan 2007
      • 55

      #3
      Thanks for your help,
      according to your suggestion i used
      Spreadsheet::Wr iteExcel for excel sheet generation and now i am able to
      create excel sheet using perl.
      Thanks once again....

      Comment

      • miller
        Recognized Expert Top Contributor
        • Oct 2006
        • 1086

        #4
        Originally posted by rahatekarabhije et
        Thanks for your help,
        according to your suggestion i used
        Spreadsheet::Wr iteExcel for excel sheet generation and now i am able to
        create excel sheet using perl.
        Thanks once again....
        Excellent. Glad I could help.

        - Miller

        Comment

        Working...