PhpSpreadsheet
PhpSpreadsheet copied to clipboard
No alignment handling in ods writer
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?
Assigned alignment to cells are written to ods file.
What is the current behavior?
Assigned alignments are ignored.
What are the steps to reproduce?
Please provide a Minimal, Complete, and Verifiable example of code that exhibits the issue without relying on an external Excel file or a web server:
<?php
require __DIR__ . '/vendor/autoload.php';
// Create new Spreadsheet object
$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet();
// add code that show the issue here...
$sheet = $spreadsheet->setActiveSheetIndex(0);
$sheet->getCell('A1', true)->setValue('XXXXXXXXXX');
$sheet->getCell('A2', true)->setValue('X');
$sheet->getStyle('A2')->getAlignment()
->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER);
$writer = \PhpOffice\PhpSpreadsheet\IOFactory::CreateWriter($spreadsheet, 'Ods');
$writer->save('buggy.ods');
Which versions of PhpSpreadsheet and PHP are affected?
current - installed on January 11th
Solution
see: https://github.com/PHPOffice/PhpSpreadsheet/discussions/1795