Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A reference to a cell containing a string starting with "#" leads to errors in the generated xlsx. #1533

Closed
keylevel opened this issue Jun 16, 2020 · 2 comments

Comments

@keylevel
Copy link

This is:

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

What is the expected behavior?

That a valid spreadsheet be produced when a cell contains a reference to another cell.

What is the current behavior?

Excel reports an error when opening a file that has been created with a reference to a cell that contains a string that starts with '#'.

What are the steps to reproduce?

The example below sets 'A1' to "#define M" and sets 'A2' as a reference to this.

The xlsx file that is produced gets an "Alert" dialog showing "We found a problem with some content in ’test.xlsx’. Do you want us to try to recover as much as we can? If you trust the source of this workbook, click Yes." when it is opened with Excel.

Changing the content of 'A1' to "'#define M" (note the extra ' at the start) results in the generation of a valid file.

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

// Create new Spreadsheet object
$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet();

// add code that show the issue here...
$sheet = $spreadsheet->getActiveSheet();

$sheet->setCellValueExplicit( "A1", "#define M",  \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_STRING );
$sheet->setCellValue( "A2", "=A1" );

$writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Xlsx');
$writer->save('./test.xlsx');


### Which versions of PhpSpreadsheet and PHP are affected?
PhpSpreadsheet 1.13.0, PHP 7.3.11
MarkBaker pushed a commit that referenced this issue Jun 19, 2020
Code assumes that formula whose result starts with # indicates error.
Change to check entire result against error list in Functions.
@keylevel
Copy link
Author

Thanks guys - I've copied that patch to my setup and can confirm that everything is now working as expected.

Should I close this issue now, or would it be better to wait until it is in a tagged release?

@MarkBaker
Copy link
Member

The fix is now included in the 1.14.0 release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants