PHPExcel can't calculate OFFSET() function wit

2019-09-01 10:25发布

问题:

I am using PhpExcel 1.8.0 and I have faced with the problem. PhpExcel can't calculate formula OFFSET() with 4 arguments:

"Price Sheet!A27 -> Program Settings!H2 -> Formula Error: Wrong number of arguments for OFFSET() function: 4 given, either 3 or 5 expected"

But in description of this formula i have found that this argument "width" is optional:

"It is the number of columns that you want the returned range to be. If this parameter is omitted, it is assumed to be the width of range."

Can someone tell me how to fix this problem?

回答1:

Open the file Classes/PHPExcel/Calculation.php and find the entry in the $PHPExcelFunctions array for OFFSET which looks like:

'OFFSET' => array(
    'category' => PHPExcel_Calculation_Function::CATEGORY_LOOKUP_AND_REFERENCE,
    'functionCall' => 'PHPExcel_Calculation_LookupRef::OFFSET',
    'argumentCount' => '3,5',
    'passCellReference' => true,
    'passByReference' => array(true)
),

and change the argumentCount block to

'argumentCount' => '3-5',


标签: phpexcel