Skip to content

Excel "CELL" function not recalculating after spreadhsheet opened by phpspreadsheets #2581

@twistedsymphony

Description

@twistedsymphony

This is:

- [x] a bug report
- [ ] a feature request
- [ ] **not** a usage question (ask them on https://stackoverflow.com/questions/tagged/phpspreadsheet or https://gitter.im/PHPOffice/PhpSpreadsheet)

What is the expected behavior?

The Function should either retain it's original calculated value or recalculate

What is the current behavior?

the function returns "#VALUE!"

What are the steps to reproduce?

Use phpspreadsheet to open the file: test.xlsx
this file include a cell function

=CONCATENATE("Prefix ",MID(CELL("filename"),FIND("]",CELL("filename"))+1,255), " Suffix")

Then use phpspreadsheet to output the file; creating a new file. The newly output file will show the formula as un-calculated. (there may be some other requirements but the behavior can be observed in the included simplified example)

test.xlsx before opening:
file_before

ouput.xlsx produced by phpspreadsheet:
file_after

Please provide a Minimal, Complete, and Verifiable example of code that exhibits the issue without relying on an external Excel file or a web server:

<?php

require __DIR__ . '/vendor/autoload.php';

$sheetReader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader('Xlsx');
$sheetReader = $sheetReader->load('test.xlsx');

$sheetWriter = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($sheetReader, 'Xlsx');

header('Content-Type: application/vnd.ms-excel');
header("Content-Disposition: attachment; filename=\"output.xlsx\"");
$sheetWriter->save('php://output');

Which versions of PhpSpreadsheet and PHP are affected?

This was observed on php 7.4 and phpspreadsheet 1.21.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions