Posted on 2007-02-19 21:43:05-08 by zeycus
Formula is not refreshed in Excel (inside Perl)
Hi, I am new to Perl. I am trying to use the Win32::Ole module to modify and create Excel files in Perl. Everything has worked smoothly until I needed to copy the value in a specific cell from one spreadsheet to another. The original cell contains a formula, and I want to copy the value to the other spreadsheet. The problem is that the 'Value' is not what it should be. After some experiments, it seems that the cause of the problem is that that formula is using other cells that are using a Visual Basic fuction in a module of mine (if that cell contains just arithmetic, the value is calculated well). When I open that spreadsheet with a double click, it takes a fraction of second for those cells to be calculated. My hunch is that the problem lies there, that when in the perl code I try to get the value, that is hapenning before any calculation of the value using my module takes place. After opening the spreadsheet with
my $Book2 = $Excel-&gt Workbooks-&gtOpen("r:/MIGUEL/valoracion/2006_01_25_Boiro/".$fileName); my $Sheet2 = $Book2-&gtWorksheets("Valor Boiro"); ...
I have tried to execute things like:
$Excel-&gt Calculate; $Sheet2-&gt Calculate; $Sheet2-&gt Cells(24, 2)-&gt Calculate;
to force the recalculation, but it seems to have no effect. What should I do??
Direct Responses: Write a response
Perl Weekly newsletter
A free weekly newsletter for people who are busy to read all the blogs. click here to check it out.