PHPOffice / PhpSpreadsheet

A pure PHP library for reading and writing spreadsheet files
https://phpspreadsheet.readthedocs.io
MIT License
13.35k stars 3.47k forks source link

Prevent removal of all styles from ods #2622

Open MrNoScript opened 2 years ago

MrNoScript commented 2 years ago

This is:

What is the expected behavior?

Keep all styles and layout settings when opening, editing and saving an ods spreadsheet file

What is the current behavior?

Removes all styles and layout settings when opening, editing and saving an ods spreadsheet file.

What are the steps to reproduce?

Using this template spreadsheet, open the file using the Ods Reader (Reader\Ods). Use IOFactory::createWriter to export the file.

All styles from the original ods have been lost.

<?php

require_once __DIR__ . '/vendor/autoload.php';

$reader = new \PhpOffice\PhpSpreadsheet\Reader\Ods();
$spreadsheet = $reader->load(__DIR__ . '/gift_aid_schedule.ods');

$writer = PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Ods');
$writer->save(__DIR__ . '/output.ods');

Which versions of PhpSpreadsheet and PHP are affected?

Unknown - not tested on versions below 1.22 PHP Version 8.1.3

Rgemini commented 2 years ago

This definitely happens using PhpSpreadsheet ^1.24 and PHP 7.4.10 (Windows 10, XAMPP)

My code reads in an .ods workbook and accesses the styles to identify which cells I want, by background colour (#FFFF00) and by border-bottom being set.

All the loaded cells have style
fillType:none, startColor:FFFFFFFF endColor:FF000000 and borders->bottom->borderStyle "none"

This is a stopper for me. Please fix if you can!