Skip to content

Commit 0e7ee37

Browse files
authored
Merge pull request #2695 from PHPOffice/Error-Handling-Spill-Calc
Add basic support for Error functions when the error is #SPILL! or #CALC!
2 parents dae5dfd + 21b784f commit 0e7ee37

File tree

4 files changed

+22
-1
lines changed

4 files changed

+22
-1
lines changed

src/PhpSpreadsheet/Calculation/Information/ErrorValue.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public static function isError($value = '')
4747
return false;
4848
}
4949

50-
return in_array($value, ExcelError::$errorCodes);
50+
return in_array($value, ExcelError::$errorCodes) || $value === ExcelError::CALC();
5151
}
5252

5353
/**

src/PhpSpreadsheet/Calculation/Information/ExcelError.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ class ExcelError
2222
'num' => '#NUM!',
2323
'na' => '#N/A',
2424
'gettingdata' => '#GETTING_DATA',
25+
'spill' => '#SPILL!',
2526
];
2627

2728
/**
@@ -45,6 +46,10 @@ public static function type($value = '')
4546
++$i;
4647
}
4748

49+
if ($value === self::CALC()) {
50+
return 14;
51+
}
52+
4853
return self::NA();
4954
}
5055

tests/data/Calculation/Information/ERROR_TYPE.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,12 @@
5353
7,
5454
'#N/A',
5555
],
56+
[
57+
9,
58+
'#SPILL!',
59+
],
60+
[
61+
14,
62+
'#CALC!',
63+
],
5664
];

tests/data/Calculation/Information/IS_ERROR.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,14 @@
4949
true,
5050
'#N/A',
5151
],
52+
[
53+
true,
54+
'#SPILL!',
55+
],
56+
[
57+
true,
58+
'#CALC!',
59+
],
5260
[
5361
false,
5462
'TRUE',

0 commit comments

Comments
 (0)