PHPOffice / PhpSpreadsheet

A pure PHP library for reading and writing spreadsheet files
https://phpspreadsheet.readthedocs.io
MIT License
13.28k stars 3.43k forks source link

Error on StringValueBinder `convertFormula` check #3987

Closed marlocorridor closed 5 months ago

marlocorridor commented 5 months ago

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?

Format cells to formula type when starts with "=" and convertFormula property is set to true

What is the current behavior?

Cell value prefixed with qoute when starts with "=" and convertFormula property is set to true

What are the steps to reproduce?

  1. Use the PhpOffice\PhpSpreadsheet\Cell\StringValueBinder as Binder.
  2. Set a cell value "=ROW()-1"

What features do you think are causing the issue

Does an issue affect all spreadsheet file formats? If not, which formats are affected?

~ not sure

Which versions of PhpSpreadsheet and PHP are affected?

1.29.0

oleibman commented 5 months ago

StringValueBinder is working as expected. See https://phpspreadsheet.readthedocs.io/en/latest/topics/accessing-cells/#using-value-binders-to-facilitate-data-entry. In particular, "By default, the StringValueBinder will cast any datatype passed to it into a string. However, there are a number of settings which allow you to specify that certain datatypes shouldn't be cast to strings, but left "as is":". If you want formulas to not be converted to strings, you must specify

$stringValueBinder->setFormulaConversion(false)
oleibman commented 5 months ago

Closing. Person reporting the issue indicated agreement with this assessment in the linked PR.