Skip to content

Problem with formulas #7

@wolverine4277

Description

@wolverine4277

Hi, I'm using your library with PHP v7.4.33 and have a problem assigning formulas to cells.

// Create a new PHPExcel object
$objPHPExcel = new PHPExcel();

// Set some values in A1 to A5 for demonstration
$objPHPExcel->getActiveSheet()->setCellValue('A1', 10);
$objPHPExcel->getActiveSheet()->setCellValue('A2', 20);
$objPHPExcel->getActiveSheet()->setCellValue('A3', 30);
$objPHPExcel->getActiveSheet()->setCellValue('A4', 40);
$objPHPExcel->getActiveSheet()->setCellValue('A5', 50);

// Set the formula in a specific cell (e.g., B1)
$objPHPExcel->getActiveSheet()->setCellValue('B1', '=AVERAGE(A1:A5)');
//$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(1, 1, '=AVERAGE(A1:A5)'); // Same result as above line

// Save the spreadsheet to a file
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
$objWriter->setPreCalculateFormulas(false); 
$objWriter->save('example.xlsx');

I understand that this code results in an excel with the formula =AVERAGE(A1:A5) in cell B1 but instead of that the cell B1 have a the text =AVERAGE(A1:A5), not the formula that shows the value 30.

I try with and old versión of the library (version 1.8.0, 2014-03-02) and the same code work fine.
I miss something new to configure in this version?
I need to update to PHP 7.4.33 and I appreciate any help!
Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions