-
-
Notifications
You must be signed in to change notification settings - Fork 640
Added support for cell formats when writing Excel files #668
Conversation
Verified that @eisberg has signed the CLA. Thanks for the pull request! |
Any update regarding this?! |
I'm really looking forward to the confirmation of this request, too. |
} else { | ||
$this->registeredFormats[$format] = $styleId; | ||
|
||
if (isset(self::$builtinNumFormatToIdMapping[$format])) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick: can be simplified $id = self::$builtinNumFormatToIdMapping[$format] ?? $this->formatIndex++;
*/ | ||
public function getFormatIdForStyleId($styleId) | ||
{ | ||
return (isset($this->styleIdToFormatsMappingTable[$styleId])) ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick: can be simplified: return $this->styleIdToFormatsMappingTable[$styleId] ?? null;
$this->assertEquals( | ||
1, | ||
$formatsDomElement->getAttribute('count'), | ||
'There should be 2 formats, including the 1 default ones' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
including the default one
* | ||
* @param Style $style | ||
*/ | ||
protected function registerFormat(Style $style) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you add a test here? See StyleRegistryTest.php for examples
@@ -88,6 +88,9 @@ private function mergeCellProperties(Style $styleToUpdate, Style $style, Style $ | |||
if (!$style->getBorder() && $baseStyle->shouldApplyBorder()) { | |||
$styleToUpdate->setBorder($baseStyle->getBorder()); | |||
} | |||
if (!$style->getFormat() && $baseStyle->shouldApplyFormat()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe add a test in StyleBuilderTest?
6c011a3
to
29bb8d3
Compare
Thanks for the PR! |
As a follow-up, we need to update the documentation. |
Is this a XSLX only feature? Does ODS not have cell formats? |
Right! We should also add that feature to ODS. Though I figured that asking people to implement both XLSX and ODS for every feature is too demanding. Usually people only need a feature for a specific file format. That's why I merged that one. See #687 |
@adrilo Okay. I respect that - but I disagree. I do not think it is to demanding do expect a fully implemented feature and docs in a PR. This repo has > 2600 stars and is heavily used. We can demand something ;)
We use XLSX and ODS. |
Added support for cell formats when writing Excel files
Example: