setDecimals($decimals); $this->setThousandsSeparator($thousandsSeparator); $this->setLocale($locale); } public function setThousandsSeparator(bool $thousandsSeparator = self::WITH_THOUSANDS_SEPARATOR): void { $this->thousandsSeparator = $thousandsSeparator; } /** * As MS Excel cannot easily handle Lakh, which is the only locale-specific Number format variant, * we don't use locale with Numbers. */ protected function getLocaleFormat(): string { return $this->format(); } public function format(): string { return sprintf( '%s0%s', $this->thousandsSeparator ? '#,##' : null, $this->decimals > 0 ? '.' . str_repeat('0', $this->decimals) : null ); } }