From 7a73f5b2cd52cb7a4d301fdbe688e67b1dce50af Mon Sep 17 00:00:00 2001 From: willkensonh Date: Mon, 15 Oct 2018 14:19:31 +1100 Subject: [PATCH] killmenow --- .../Writer/XLSX/Manager/OptionsManager.php | 2 +- .../Writer/XLSX/Manager/Style/StyleManager.php | 18 +++++++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/Spout/Writer/XLSX/Manager/OptionsManager.php b/src/Spout/Writer/XLSX/Manager/OptionsManager.php index 53718bc..0c08b5a 100644 --- a/src/Spout/Writer/XLSX/Manager/OptionsManager.php +++ b/src/Spout/Writer/XLSX/Manager/OptionsManager.php @@ -14,7 +14,7 @@ class OptionsManager extends OptionsManagerAbstract { /** Default style font values */ const DEFAULT_FONT_SIZE = 12; - const DEFAULT_FONT_NAME = 'Calibri'; + const DEFAULT_FONT_NAME = 'Arial'; /** @var StyleBuilder Style builder */ protected $styleBuilder; diff --git a/src/Spout/Writer/XLSX/Manager/Style/StyleManager.php b/src/Spout/Writer/XLSX/Manager/Style/StyleManager.php index 0a72ba9..4a608ba 100644 --- a/src/Spout/Writer/XLSX/Manager/Style/StyleManager.php +++ b/src/Spout/Writer/XLSX/Manager/Style/StyleManager.php @@ -225,7 +225,7 @@ EOD; $styleId = $style->getId(); $fillId = $this->getFillIdForStyleId($styleId); $borderId = $this->getBorderIdForStyleId($styleId); - $numberFormatId = !empty($style->getNumberFormat()) ? $style->getNumberFormat()->getId() : 0; + $numberFormatId = $this->getNumberFormatIdForStyleId($styleId); $content .= 'styleRegistry->getBorderIdForStyleId($styleId) ?: 0); } + /** + * Returns the fill ID associated to the given style ID. + * For the default style, we don't a border. + * + * @param int $styleId + * @return int + */ + private function getNumberFormatIdForStyleId($styleId) + { + // For the default style (ID = 0), we don't want to override the border. + // Otherwise all cells of the spreadsheet will have a border. + $isDefaultStyle = ($styleId === 0); + + return $isDefaultStyle ? 0 : ($this->styleRegistry->getNumberFormatIdForStyleId($styleId) ?: 0); + } + /** * Returns the content of the "" section. *