Skip to content

Error open file Xlsx when modify value #4128

@Fabacks

Description

@Fabacks

Good morning,

Since switching to version >= 2.2, the "setCellValue" method causes an error when opening Excel.
The error is : "We found a problem in the content of XXX, but we can try to recover as much content as possible.".
It only produces this with the "Xlsx" format. I tried to reproduce the error with minimal code. But, if you open the file and save without modifying a single line, the file opens correctly.

The function "error_reporting(E_ALL)" gives no error.

Thank you so much

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 are the steps to reproduce?

Execute the code

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';

$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet();
$spreadsheet->getActiveSheet()->setCellValue('D1', 'MyDate');

$path = __DIR__.'/file_example.xlsx';
$writer = IOFactory::createWriter($spreadsheet, 'Xlsx');
$writer->save($path);
?>

// add code that show the issue here...

If this is an issue with reading a specific spreadsheet file, then it may be appropriate to provide a sample file that demonstrates the problem; but please keep it as small as possible, and sanitize any confidential information before uploading.
file_example.xlsx
error excel open

What features do you think are causing the issue

  • Reader
  • [ X] Writer
  • Styles
  • Data Validations
  • Formula Calculations
  • Charts
  • AutoFilter
  • Form Elements

Which versions of PhpSpreadsheet and PHP are affected?

Phpspreasheet >=2.2
PHP >= 8.1
Excel 2016
Environment Windows
Langue French

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