tejasvinnakota has asked for the wisdom of the Perl Monks concerning the following question:

Hi I have been using perl for quite sometime now , basically for creating windows excel sheets using use Excel::Writer::XLSX; . Below is the code snippet just for writing a formula to a cell

use Excel::Writer::XLSX; use Spreadsheet::XLSX; my $workbook = Excel::Writer::XLSX->new( "MY_WORKBOOK"); my $worksheet = $workbook->add_worksheet( "One" ); my $row =0 ; my $col =0; my $formula = qq/=IF(C${formularow}="Manual",SUMIFS(GL!\$L:\$L, GL!\$ +A:\$A, Compare!\$B${formularow}, GL!\$P:\$P, Compare!\$C${formularow} +, GL!\$N:\$N, Compare!\$D${formularow}, GL!\$Q:\$Q, Compare!\$F${form +ularow}),SUMIFS(GL!\$L:\$L, GL!\$A:\$A, Compare!\$B${formularow}, GL! +\$P:\$P, Compare!\$C${formularow}, GL!\$N:\$N, Compare!\$D${formularo +w}, GL!\$O:\$O, Compare!E${formularow}, GL!\$Q:\$Q, Compare!\$F${form +ularow}))/; $worksheet->write_formula( $row,$col,$formula,$num_format);

The above code writes the formula into excel sheet and the formula is calculated when i open the excel sheet in windows. Is there a way that i can get this value in perl itself. Known Issue for Spreadsheet::WriteExcel This module cannot read the values of formulas from files created with Spreadsheet::WriteExcel unless the user specified the values when creating the file (which is generally not the case). The reason for this is that Spreadsheet::WriteExcel writes the formula but not the formula result since it isn't in a position to calculate arbitrary Excel formulas without access to Excel's formula engine. Is it the same with XLSX too.or is there a way that i can get the values not formula's while reading the excel

  • Comment on read the values of formulas from files created with Spreadsheet::XLSX
  • Download Code

Replies are listed 'Best First'.
Re: read the values of formulas from files created with Spreadsheet::XLSX
by hdb (Monsignor) on Feb 18, 2015 at 11:13 UTC

    You already answer your own question: without Excel you cannot calculate the formulas. Consider moving to Win32::OLE (assuming you are on Windows and have Excel installed).

Re: read the values of formulas from files created with Spreadsheet::XLSX
by Laurent_R (Canon) on Feb 18, 2015 at 07:48 UTC
    Hmm. I do no have an answer to your question, but would like to say that what you are asking for is not what you (or others) would usually want. The great thing about spreadsheets is precisely that they are dynamic, their formulas get recalculated whenever the parameters used in these formulas change. If you want to get the computed result, why don't you calculate simply the result in your program and store the result in the spreadsheet?

    Je suis Charlie.