Skip to content
This repository has been archived by the owner on May 26, 2022. It is now read-only.

ODS writer does not recognise style changes when calculating repeated columns #732

Open
acoulton opened this issue Mar 19, 2020 · 0 comments

Comments

@acoulton
Copy link

The code in WorksheetManager to detect whether a cell is repeated only considers the cell value.

Unfortunately this means a row with repeated values but different styles is not rendered correctly.

$s     = WriterEntityFactory::createODSWriter();
$red   = (new StyleBuilder())->setBackgroundColor('ff0000')->build();
$green = (new StyleBuilder())->setBackgroundColor('00ff00')->build();

$s->openToFile('incorrect-repeat.ods');
$s->addRow(
    WriterEntityFactory::createRow(
        [
            WriterEntityFactory::createCell('X', $red),
            WriterEntityFactory::createCell('X', $red),
            WriterEntityFactory::createCell('X', $green)
        ]
    )
);
$s->addRow(
    WriterEntityFactory::createRow(
        [
            WriterEntityFactory::createCell('X', $red),
            WriterEntityFactory::createCell('X', $red),
            WriterEntityFactory::createCell('Y', $green),
            WriterEntityFactory::createCell('X', $red)
        ]
    )
);
$s->close();

Should produce this - and it does if you use an XLSX writer:
image

But it actually produces this:
image

Note that C1 should have a green background, but doesn't because it is treated as a repeat of A1/B1.

Unfortunately the "repeated cell" check happens before the style ID is allocated, so I think fixing this would have to involve comparing the cell styles directly?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant