< ^ >

Rewriting an Excel binary file


    #!/usr/bin/perl -w

    use strict;
    use Spreadsheet::ParseExcel::SaveParser;

    # Open the template with SaveParser
    my $parser   = new Spreadsheet::ParseExcel::SaveParser;
    my $template = $parser->Parse('template.xls');

    my $sheet    = 0;
    my $row      = 0;
    my $col      = 0;

    # Get the format from the cell
    my $format   = $template->{Worksheet}[$sheet]
                            ->{Cells}[$row][$col]
                            ->{FormatNo};


    # Write data to some cells
    $template->AddCell(0, $row, $col, "Hello YAPC::Eu", $format);


    # The SaveParser SaveAs() method returns a reference to a
    # Spreadsheet::WriteExcel object.
    my $workbook = $template->SaveAs('newfile.xls');


    # Use Spreadsheet::WriteExcel methods
    my $worksheet  = ($workbook->sheets())[0];

    $worksheet->write($row+5, $col, "New stuff here");


    __END__