You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- [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)
What is the expected behavior?
When a column width is set it should be exported and have an effect in Libreoffice.
Something like style:column-width="12.118cm" is expected in content.xml
What is the current behavior?
Custom column width and autosize have no effect, columns always have the default width in Libreoffice. content.xml contains no column width setting.
<?phprequire__DIR__ . '/vendor/autoload.php';
// Create new Spreadsheet object$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet();
$sheet = $spreadsheet->getActiveSheet();
$sheet->setCellValue('A1', 'not so long text');
$sheet->setCellValue('A2', 'longer text to test column width');
$sheet->setCellValue('B1', 0.51);
$sheet->setCellValue('B2', 100051);
$sheet->getColumnDimension('A')->setWidth(666);
#$sheet->getColumnDimension('A')->setAutoSize(true);#$sheet->getColumnDimension('B')->setWidth(333);$sheet->getColumnDimension('B')->setAutoSize(true);
$writer = new \PhpOffice\PhpSpreadsheet\Writer\Ods($spreadsheet);
$writer->save('./odsFormating.ods');
Which versions of PhpSpreadsheet and PHP are affected?
phpspreadsheet 1.18.0, php 7.3.31
The text was updated successfully, but these errors were encountered:
I have the same issue. I modified the script above somewhat as follows
<?php
require 'vendor/autoload.php';
$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet();
$sheet = $spreadsheet->getActiveSheet();
$sheet->setCellValue('A1', 'not so long text');
$sheet->setCellValue('A2', 'longer text to test column width');
$sheet->setCellValue('B1', 0.51);
$sheet->setCellValue('B2', 100051);
$sheet->getColumnDimension('A')->setAutoSize(true);
$sheet->getColumnDimension('B')->setAutoSize(true);
$writer1 = new \PhpOffice\PhpSpreadsheet\Writer\Ods($spreadsheet);
$writer2 = new \PhpOffice\PhpSpreadsheet\Writer\Xlsx($spreadsheet);
$writer3 = new \PhpOffice\PhpSpreadsheet\Writer\Html($spreadsheet);
$writer1->save('test.ods');
$writer2->save('test.xlsx');
$writer3->save('test.html');
The created test.html and test.xlsx file both have the expected column widths, but test.ods has default widths.
This is:
What is the expected behavior?
When a column width is set it should be exported and have an effect in Libreoffice.
Something like
style:column-width="12.118cm"
is expected in content.xmlWhat is the current behavior?
Custom column width and autosize have no effect, columns always have the default width in Libreoffice. content.xml contains no column width setting.
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:
Which versions of PhpSpreadsheet and PHP are affected?
phpspreadsheet 1.18.0, php 7.3.31
The text was updated successfully, but these errors were encountered: