I first set a cell to be text
$spreadsheet->getActiveSheet()->getStyle( "A1" )->getNumberFormat()
->setFormatCode(\PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_TEXT);
Then I set the cell value to a string that may be interpreted as a number
$spreadsheet->getActiveSheet()->setCellValue( "A1", "10.20" );
When I open the Excel file the cell A1
is actually TEXT but the value is
10,2
(my Excel has a preference set to use comma as decimal separator).
So despite the text format and the fact that I also pass a string to setCellValueByColumnAndRow()
the trailing zero is lost and dot converted to comma.
I want the cell to be 10.20
.
What am I missing?
I figured it out:
I need to use