Skip to content

[Feature Request]: Ability to set built-in styles for a cell (XLSX) #1632

@serverdevil

Description

@serverdevil

This is:

- [ ] a bug report
- [x] a feature request
- [x] **not** a usage question (ask them on https://stackoverflow.com/questions/tagged/phpspreadsheet or https://gitter.im/PHPOffice/PhpSpreadsheet)

A feature request to support setting built-in styles on a cell when writing to XLSX. We are setting 0 a.k.a Normal for all. Would be good to have ability to set from the list of built-in types e.g. Hyperlink.
setHyperlink is useful to set the cell's hyperlink but the styling does not reflect it.

Code reference (\PhpSpreadsheet\Reader\Xlsx\Styles.php).

//    Cell Styles
       if ($this->styleXml->cellStyles) {
           foreach ($this->styleXml->cellStyles->cellStyle as $cellStyle) {
               if ((int) ($cellStyle['builtinId']) == 0) {
                   if (isset($this->cellStyles[(int) ($cellStyle['xfId'])])) {
                       // Set default style
                       $style = new Style();
                       $this->readStyle($style, $this->cellStyles[(int) ($cellStyle['xfId'])]);
                        // normal style, currently not using it for anything
                   }
               }
           }
       }

Essentially, one of these.
image

Thoughts?

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