Friday, October 7, 2011

Installation of Spreadsheet::WriteExcel module for Perl

    Spreadsheet::WriteExcel module can be used to write/edit excel files. The installation procedure for this module is as given below.

1. Download

2. Unzip the module as follows, tar -zxvf Spreadsheet-WriteExcel-2.xx.tar.gz.
3. The module can be installed using the standard Perl procedure:
          perl Makefile.PL
        make test
        make install
    # You may need to be root
         make clean      # or make realclean

That's all !!!!!. Now you can write Perl programs to edit an Excel.

Sample program :

    #!/usr/bin/perl -w
    use strict;
    use Spreadsheet::WriteExcel;
    # Create a new Excel workbook
    my $workbook = Spreadsheet::WriteExcel->new("regions.xls");
    # Add some worksheets
    my $north = $workbook->addworksheet("North");
    my $south = $workbook->addworksheet("South");
    my $east  = $workbook->addworksheet("East");
    my $west  = $workbook->addworksheet("West");
    # Add a caption to each worksheet
    foreach my $worksheet (@{$workbook->{worksheets}}) {
       $worksheet->write(0, 0, "Sales");

        # Write some data
    $north->write(0, 1, 200000);
    $south->write(0, 1, 100000);
    $east->write (0, 1, 150000);
    $west->write (0, 1, 100000);
    # Set the active worksheet

No comments:

Post a Comment