PHP_XLSXWriter icon indicating copy to clipboard operation
PHP_XLSXWriter copied to clipboard

When equal sign is the first letter in cell, it is always treated as formula, causing excel reports data in sheet to be corrupted

Open pstepanek1 opened this issue 6 years ago • 1 comments

It would be great, if string type of the cell is always treated as string, no matter what the content is. The issue I believe is in order of evaluation in writeCell function.

1st is (is_string($value) && $value{0}=='=') ---> set formula later is ($num_format_type=='n_string') ---> set string

Formula type should be examined after the string type (which is supposed to be predefined type). This way string overrides the formula type and excel let you write = sign as the first letter in the cell without any problem being reported.

pstepanek1 avatar Feb 27 '19 16:02 pstepanek1

Does anybody know any workarounds for this issue?

@mk-j will you accept the pull request with fix?

Magomogo avatar Nov 20 '20 02:11 Magomogo

If you can detect that your data starts with "=" just prepend a single quote on it, just like in ex01-multiple-sheets.php

mk-j avatar May 31 '23 22:05 mk-j