doy / spreadsheet-parsexlsx

parse XLSX files
http://metacpan.org/release/Spreadsheet-ParseXLSX
27 stars 35 forks source link

How to get formula for a cell? #86

Open bulrush15 opened 6 years ago

bulrush15 commented 6 years ago

I don't see any option to get the formula to a cell. Is there even a method to return the formula? I need to copy a tab from one XLSX file to another XLSX file complete with formulas, using Perl.

This appears to show a solution: https://stackoverflow.com/questions/33799378/perl-excel-spreadsheetparsexlsx-get-cell-value-with-formula

print $cell->{Formula}."\n";

This is not documented. Can someone document all the cell properties? Text from the post:

my $parser             = Spreadsheet::ParseXLSX->new();
my $oBook              = $parser->parse("$excelfile");
my $worksheet          = $oBook->worksheet("first");
my $cell = $worksheet->{Cells}[1][0]; # A1
print Dumper($cell); # Requires Data::Dumper

The result of the Dump Looks like this:

$VAR1 = bless( {
             'Merged' => '',
             'Type' => 'Numeric',
             'Val' => 0,
             '_Value' => '0.000',
             'FormatNo' => 3,
             'Formula' => 'TD!A2',
             'Format' => bless( {