This is:
- [X] a bug report
- [ ] a feature request
- [ ] **not** a usage question (ask them on https://stackoverflow.com/questions/tagged/phpspreadsheet or https://gitter.im/PHPOffice/PhpSpreadsheet)
I'm trying to format a datetime in a cell. It doesn't work with ods file but same code with Xlsx writer works perfectly.
Cell with
11/09/2018 17:05
43354,7118055556
<?php
$sheet->setCellValueByColumnAndRow(4, $ligne, \PhpOffice\PhpSpreadsheet\Shared\Date::PHPToExcel($myobject->getDate()));
$sheet->getStyleByColumnAndRow(4, $ligne)->getNumberFormat()->setFormatCode('dd/mm/yyyy hh:mm');
$writer = IOFactory::createWriter($spreadsheet, 'Ods');
$fileName = 'myfile.ods';
$temp_file = tempnam(sys_get_temp_dir(), $fileName);
$writer->save($temp_file);
But it works with
$writer = IOFactory::createWriter($spreadsheet, 'Xlsx');
$fileName = 'myfile.xlsx';
PhpSpreadsheet 1.4.0
PHP 5.6
I encounter the same issue with PHP 7.2
phpoffice/phpspreadsheet 1.4.0
PHP 7.2.11
This issue persists with version 1.5.0.
Same issue and number format doesn't work either (FORMAT_PERCENTAGE for instance). It seems that ods format shows only the internal representation of numbers (including dates), but not the formated value.
On the other way, xlsx, xls and csv writers work perfectly.
phpoffice/phpspreadsheet 1.6.0
PHP 7.2.10
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
If this is still an issue for you, please try to help by debugging it further and sharing your results.
Thank you for your contributions.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
If this is still an issue for you, please try to help by debugging it further and sharing your results.
Thank you for your contributions.
This is still an issue in the latest version.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
If this is still an issue for you, please try to help by debugging it further and sharing your results.
Thank you for your contributions.
Still issue
I encountered this issue as well (PhpSpreadsheet 1.16.0, PHP 7.4), with the percentage format. It works for the Xls writer as a format, but I guess Ods works differently.
For a cell with the value "53.57%", the AdvancedValueBinder changes it to 0.5357, and sets a number format in the styles.
In the case of Ods, it should generate an XML node like this:
<table:table-cell table:style-name="ce4"
office:value-type="percentage"
office:value="0.5357"
calcext:value-type="percentage">
<text:p>53,57 %</text:p>
</table:table-cell>
Is there a fundamental issue with these points?
office:value-type and calcext:value-type)office:value attribute
Most helpful comment
Still issue