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

Style not present when editing existing spreadsheet #855

Open
nbyloff opened this issue Jan 19, 2022 · 0 comments
Open

Style not present when editing existing spreadsheet #855

nbyloff opened this issue Jan 19, 2022 · 0 comments

Comments

@nbyloff
Copy link

nbyloff commented Jan 19, 2022

I followed the example here on editing an existing sheet. The main thing I noticed is it is not including the styles I included in the sheet. I have multiple jobs that each are responsible for creating a sheet. After the first job is run, each subsequent job will pick up the same XLSX output file, first recreate each sheet (using the method in the link above) then create a new blank sheet to do it's own work.

I use the StyleBuilder to create bold, background color, etc. but it only ever shows up on the last sheet. Looking at the code block below, the $row object has a style property, but it does not show up in the output.

if (isset($reader)) {
      foreach ($reader->getSheetIterator() as $sheetIndex => $sheet) {
        if ($sheetIndex > 0) {
          $writer->addNewSheetAndMakeItCurrent();
        }
        $newSheet = $writer->getCurrentSheet();
        $newSheet->setName($sheet->getName());

        foreach ($sheet->getRowIterator() as $rowIndex => $row) {

          $writer->addRow($row); // this $row object has style present, but it is not displayed in the file
        }
      }
      $reader->close();
    }
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