Spreadsheet::Parse & Write Excel

Discussion in 'Perl Misc' started by Justin C, Oct 30, 2007.

  1. Justin C

    Justin C Guest

    I get the following error when running my script:

    Can't locate object method "get_xf_index" via package
    "Spreadsheet::parseExcel::Format" at
    /usr/local/share/perl/5.8.8/Spreadsheet/WriteExcel/Worksheet.pm line
    1453

    It looks odd to me. It's saying it can't locate an object method from
    one module in the second module. The two modules are un-related (apart
    from the fact that they both deal with Excel files), neither is
    dependant on the other.

    This is probably due to the way I'm using ...::WriteExcel, and stems
    from my not understanding the documentation for ...::parseExcel. It
    looks like it's written very much for OO coding, I'm not that advanced
    and have been, probably, banging my head against it too hard.

    Here is some code:

    #!/usr/bin/perl

    use warnings;
    use strict;
    use Spreadsheet::parseExcel;
    use Spreadsheet::WriteExcel;

    my $inFile = "some.xls";
    my $outFile = "output.xls";
    my $lastCol = 9; # We don't want the data beyond this point
    my $firstRow = 4;# counting from 0, 0-3 are the front page for printing
    my $lastRow;

    my $inBook = Spreadsheet::parseExcel::Workbook->Parse($inFile);
    my $outBook = Spreadsheet::WriteExcel->new($outFile);
    my $outSheet = $outBook->add_worksheet();

    foreach my $inSheet(@{$inBook->{Worksheet}}) { # there's only one
    $lastRow = $inSheet->{MaxRow};

    foreach my $row ( $firstRow .. $lastRow) {
    foreach my $col ( 0 .. $lastCol) {
    # get contents of cell
    my $cellcontent = $inSheet->{Cells}[$row][$col]->{_Value};
    my $cellFormat = $inSheet->{Cells}[$row][$col]->{Format};
    # write contents of cell to new worksheet
    $outSheet->write_string($row-3, $col-5, $cell, $cellFormat);
    }
    }
    }

    *** END ***

    $cellFormat contains a hash reference, AFAICT. I was hoping that that
    would be accepted by the ...::WriteExcel and generate what I want.

    Can anyone spot anything obviously wrong with the above that may help
    me? Are there any Spreadsheet::[Parse|Write]Excel experts here who have
    suggestions?

    I thank you for your help with this.

    Justin.

    --
    Justin C, by the sea.
     
    Justin C, Oct 30, 2007
    #1
    1. Advertising

  2. Justin C

    Justin C Guest

    On 2007-10-30, Jim Gibson <> wrote:
    >
    > Spreadsheet::parseExcel and Spreadsheet::WriteExcel are separate
    > modules that have no relationship to each other and were written by
    > different authors. In particular, they each have their own concepts of
    > a "Format" object or class, and these are not shared. You cannot fetch
    > the format of a cell in an existing spreadsheet and transfer it whole
    > to a new spreadsheet.


    That appears to be the crux of it.


    > You are going to have to play around with
    > extracting the various pieces of the existing cell format and transfer
    > each piece to the new spreadsheet using the syntax of
    > Spreadsheet::WriteExcel.


    Looks like a fun time is going to be had by all then!!!

    Thank you for your reply. It has helped me re-evaluate the problem.

    Justin.

    --
    Justin C, by the sea.
     
    Justin C, Oct 31, 2007
    #2
    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?c2hhc2hhbmsga3Vsa2Fybmk=?=

    Problem with Excel reports ::::Excel 2003 Migration To Excel 2007

    =?Utf-8?B?c2hhc2hhbmsga3Vsa2Fybmk=?=, Oct 5, 2007, in forum: ASP .Net
    Replies:
    15
    Views:
    1,541
    =?Utf-8?B?c2hhc2hhbmsga3Vsa2Fybmk=?=
    Oct 24, 2007
  2. lovelymmx
    Replies:
    1
    Views:
    107
    Guanliang Liu
    May 3, 2007
  3. Justin C
    Replies:
    4
    Views:
    170
    Justin C
    Jul 10, 2006
  4. kkappabear
    Replies:
    0
    Views:
    108
    kkappabear
    Dec 12, 2006
  5. Replies:
    1
    Views:
    269
    J. Gleixner
    Jan 14, 2008
Loading...

Share This Page