PHP_XLSXWriter icon indicating copy to clipboard operation
PHP_XLSXWriter copied to clipboard

Strip equal sign when inserting formulas

Open stoppeye opened this issue 6 years ago • 0 comments

The equal sign should be stripped when inserting a formula into <f> tags (see Reference).

While Excel will still handle it correctly, it can cause errors in other applications (e.g. Google Sheets).

Adding ltrim on the value can fix this:

} elseif (is_string($value) && $value{0}=='='){
    $file->write('<c r="'.$cell_name.'" s="'.$cell_style_idx.'" t="s"><f>'.self::xmlspecialchars(ltrim($value, '=')).'</f></c>');

stoppeye avatar Aug 09 '18 08:08 stoppeye