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

Style not present when editing existing spreadsheet #855

@nbyloff

Description

@nbyloff

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();
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions