Do array results spill to other cells? #4062
-
I may be doing something wrong, so I'm wondering whether the result of array functions (e.g. Here's an example: require 'vendor/autoload.php';
use PhpOffice\PhpSpreadsheet\IOFactory;
$spreadsheet = IOFactory::load("spill.xlsx");
$calculation = $spreadsheet->getCalculationEngine();
$calculation->getDebugLog()->setWriteDebugLog(true);
$calculation->getDebugLog()->setEchoDebugLog(true);
$calculation->clearCalculationCache();
$cell = $spreadsheet->getActiveSheet()->getCell('A1');
$cell->setValue(100);
$cell = $spreadsheet->getActiveSheet()->getCell('B1');
$result = $calculation->calculate($cell);
var_dump($result);
for ($i=1; $i<=6; $i++) {
$coord = "B$i";
$cell = $spreadsheet->getActiveSheet()->getCell($coord);
echo $coord . ' : ' . $cell->getValue() . ' => ' . $cell->getCalculatedValue() . "\n";
} In this file, a list of values in column A is sorted in B1, and spills in the B column. Then, in the code, I modify A1 from 10 to 100, which I expect should change the B values. But that doesn't happen, or I don't know how to make it happen. When I run the code, I get the following:
So whereas the |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
Yes, it is expected, we do not yet have good support for array results. I have PR #3962 in draft status; you might want to test against it, in conjunction with setting ArrayReturnType in your code. This gives the full array result when you execute getCalculatedValue against B1; it does not, however, show any changes when executing getCalculatedValue against the other cells, at least not yet (that's one of the reasons why it's still in draft status). However, if you were to save the spreadsheet, you would see the expected values in the other cells when you open it. |
Beta Was this translation helpful? Give feedback.
-
Release 3.3.0 implements dynamic array functionality. |
Beta Was this translation helpful? Give feedback.
Yes, it is expected, we do not yet have good support for array results. I have PR #3962 in draft status; you might want to test against it, in conjunction with setting ArrayReturnType in your code. This gives the full array result when you execute getCalculatedValue against B1; it does not, however, show any changes when executing getCalculatedValue against the other cells, at least not yet (that's one of the reasons why it's still in draft status). However, if you were to save the spreadsheet, you would see the expected values in the other cells when you open it.