Skip to content

Commit bfb694a

Browse files
Implement missing INFO function
1 parent fc48bce commit bfb694a

File tree

5 files changed

+35
-4
lines changed

5 files changed

+35
-4
lines changed

docs/references/function-list-by-category.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ Excel Function | PhpSpreadsheet Function
189189
-------------------------|--------------------------------------
190190
CELL | **Not yet Implemented**
191191
ERROR.TYPE | \PhpOffice\PhpSpreadsheet\Calculation\Information\ExcelError::type
192-
INFO | **Not yet Implemented**
192+
INFO | \PhpOffice\PhpSpreadsheet\Calculation\Information\Info::getInfo
193193
ISBLANK | \PhpOffice\PhpSpreadsheet\Calculation\Information\Value::isBlank
194194
ISERR | \PhpOffice\PhpSpreadsheet\Calculation\Information\ErrorValue::isErr
195195
ISERROR | \PhpOffice\PhpSpreadsheet\Calculation\Information\ErrorValue::isError

docs/references/function-list-by-name-compact.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ IMSUM | ENGINEERING | Engineering\ComplexOperations
299299
IMTAN | ENGINEERING | Engineering\ComplexFunctions::IMTAN
300300
INDEX | LOOKUP_AND_REFERENCE | LookupRef\Matrix::index
301301
INDIRECT | LOOKUP_AND_REFERENCE | LookupRef\Indirect::INDIRECT
302-
INFO | INFORMATION | **Not yet Implemented**
302+
INFO | INFORMATION | Information\Info::getInfo
303303
INT | MATH_AND_TRIG | MathTrig\IntClass::evaluate
304304
INTERCEPT | STATISTICAL | Statistical\Trends::INTERCEPT
305305
INTRATE | FINANCIAL | Financial\Securities\Rates::interest

docs/references/function-list-by-name.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ IMSUM | CATEGORY_ENGINEERING | \PhpOffice\PhpSpread
295295
IMTAN | CATEGORY_ENGINEERING | \PhpOffice\PhpSpreadsheet\Calculation\Engineering\ComplexFunctions::IMTAN
296296
INDEX | CATEGORY_LOOKUP_AND_REFERENCE | \PhpOffice\PhpSpreadsheet\Calculation\LookupRef\Matrix::index
297297
INDIRECT | CATEGORY_LOOKUP_AND_REFERENCE | \PhpOffice\PhpSpreadsheet\Calculation\LookupRef\Indirect::INDIRECT
298-
INFO | CATEGORY_INFORMATION | **Not yet Implemented**
298+
INFO | CATEGORY_INFORMATION | \PhpOffice\PhpSpreadsheet\Calculation\Information\Info::getInfo
299299
INT | CATEGORY_MATH_AND_TRIG | \PhpOffice\PhpSpreadsheet\Calculation\MathTrig\IntClass::evaluate
300300
INTERCEPT | CATEGORY_STATISTICAL | \PhpOffice\PhpSpreadsheet\Calculation\Statistical\Trends::INTERCEPT
301301
INTRATE | CATEGORY_FINANCIAL | \PhpOffice\PhpSpreadsheet\Calculation\Financial\Securities\Rates::interest

src/PhpSpreadsheet/Calculation/FunctionArray.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1284,8 +1284,9 @@ class FunctionArray extends CalculationBase
12841284
],
12851285
'INFO' => [
12861286
'category' => Category::CATEGORY_INFORMATION,
1287-
'functionCall' => [Functions::class, 'DUMMY'],
1287+
'functionCall' => [Information\Info::class, 'getInfo'],
12881288
'argumentCount' => '1',
1289+
'passCellReference' => true,
12891290
],
12901291
'INT' => [
12911292
'category' => Category::CATEGORY_MATH_AND_TRIG,
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
namespace PhpOffice\PhpSpreadsheet\Calculation\Information;
4+
5+
use PhpOffice\PhpSpreadsheet\Cell\Cell;
6+
7+
class Info
8+
{
9+
/**
10+
* INFO.
11+
*
12+
* Excel Function:
13+
* =INFO(type_text)
14+
*
15+
* @param mixed $typeText String specifying the type of information to be returned
16+
* @param ?Cell $cell Cell from which spreadsheet information is retrieved
17+
*
18+
* @return string The requested information about the current operating environment
19+
*/
20+
public static function getInfo(mixed $typeText = '', ?Cell $cell = null): string
21+
{
22+
return match (is_string($typeText) ? strtolower($typeText) : $typeText) {
23+
'numfile' => $cell?->getWorksheetOrNull()?->getParent()?->getSheetCount() ?? 1,
24+
'osversion' => 'PHP ' . phpversion(),
25+
'recalc' => 'Automatic',
26+
'system' => 'PHP',
27+
default => ExcelError::VALUE(),
28+
};
29+
}
30+
}

0 commit comments

Comments
 (0)