-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Open
Description
This is:
[X] a bug report
What is the expected behavior?
Formatted numbers.
What is the current behavior?
No formatting.
What are the steps to reproduce?
<?php
require __DIR__ . '/vendor/autoload.php';
use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Writer\Ods;
$spreadsheet = new Spreadsheet();
$activeWorksheet = $spreadsheet->getActiveSheet();
$activeWorksheet->setCellValue('A1', 123456.789);
$activeWorksheet->getStyle('A1')->getNumberFormat()->setFormatCode('#,##0.00');
$writer = new Ods($spreadsheet);
$writer->save('test-fmt-01.ods');Have also tried all kind of variants like
$activeWorksheet->setCellValue([1, 1], 123456.789);
$activeWorksheet->setCellValueExplicit($loc, $val, DataType::TYPE_NUMERIC);
// ...
$activeWorksheet->getStyle('A1')->applyFromArray([
'numberFormat' => [
'formatCode' => '0,00E+00'
]
]);
$activeWorksheet->getStyle('A1')->getNumberFormat()->setFormatCode(
PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_CURRENCY_EUR
);
// ...
$writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, "Ods");
$writer->save("out/test01.ods");- dozens of more tweaks.
Have also tried all sorts of variants with numbers; as string, as int,as float, ...
If I do:
var_dump( ... getFormatCode());
... setFormatCode($fmt);
var_dump(... getFormatCode());The correct format is dumped after applying. But never applied to the written file.
Have also tried to save a file with formatting using LibreOffice then reading it with PhpSpreadsheet - but the var_dump(... getFormatCode()); only say string(7) "General". Have also tried to scan 100x100 cells but no cell has any format.
What features do you think are causing the issue
- Reader
- Writer
- Styles
- Data Validations
- Formula Calculations
- Charts
- AutoFilter
- Form Elements
Does an issue affect all spreadsheet file formats? If not, which formats are affected?
Which versions of PhpSpreadsheet and PHP are affected?
- PhpSpreadsheet 2.0.0
- PHP 8.3.3
PHPTCloud
Metadata
Metadata
Assignees
Labels
No labels