PhpSpreadsheet icon indicating copy to clipboard operation
PhpSpreadsheet copied to clipboard

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

Open serverdevil opened this issue 5 years ago • 1 comments

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?

serverdevil avatar Aug 29 '20 10:08 serverdevil

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If this is still an issue for you, please try to help by debugging it further and sharing your results. Thank you for your contributions.

stale[bot] avatar Dec 25 '20 13:12 stale[bot]