diff --git a/xlsxwriter.class.php b/xlsxwriter.class.php
index e4ebdc5eb..12ddab26e 100644
--- a/xlsxwriter.class.php
+++ b/xlsxwriter.class.php
@@ -124,8 +124,12 @@ public function writeToFile($filename)
protected function initializeSheet($sheet_name, $col_widths=array(), $auto_filter=false, $freeze_rows=false, $freeze_columns=false )
{
//if already initialized
- if ($this->current_sheet==$sheet_name || isset($this->sheets[$sheet_name]))
- return;
+ if ($this->current_sheet==$sheet_name || isset($this->sheets[$sheet_name])) return;
+
+ if (PHP_MAJOR_VERSION < 8) {
+ $oldlocale = setlocale(LC_NUMERIC, 0);
+ setlocale(LC_NUMERIC, 'C');
+ }
$sheet_filename = $this->tempFilename();
$sheet_xmlname = 'sheet' . (count($this->sheets) + 1).".xml";
@@ -188,6 +192,8 @@ protected function initializeSheet($sheet_name, $col_widths=array(), $auto_filte
$sheet->file_writer->write( '
');
$sheet->file_writer->write( '');
$sheet->file_writer->write( '');
+
+ if (PHP_MAJOR_VERSION < 8) setlocale(LC_NUMERIC, $oldlocale);
}
private function addCellStyle($number_format, $cell_style_string)
@@ -251,8 +257,12 @@ public function writeSheetHeader($sheet_name, array $header_types, $col_options
public function writeSheetRow($sheet_name, array $row, $row_options=null)
{
- if (empty($sheet_name))
- return;
+ if (empty($sheet_name)) return;
+
+ if (PHP_MAJOR_VERSION < 8) {
+ $oldlocale = setlocale(LC_NUMERIC, 0);
+ setlocale(LC_NUMERIC, 'C');
+ }
$this->initializeSheet($sheet_name);
$sheet = &$this->sheets[$sheet_name];
@@ -286,6 +296,8 @@ public function writeSheetRow($sheet_name, array $row, $row_options=null)
$sheet->file_writer->write('');
$sheet->row_count++;
$this->current_sheet = $sheet_name;
+
+ if (PHP_MAJOR_VERSION < 8) setlocale(LC_NUMERIC, $oldlocale);
}
public function countSheetRows($sheet_name = '')
@@ -364,6 +376,11 @@ public function writeSheet(array $data, $sheet_name='', array $header_types=arra
protected function writeCell(XLSXWriter_BuffererWriter &$file, $row_number, $column_number, $value, $num_format_type, $cell_style_idx)
{
+ if (PHP_MAJOR_VERSION < 8) {
+ $oldlocale = setlocale(LC_NUMERIC, 0);
+ setlocale(LC_NUMERIC, 'C');
+ }
+
$cell_name = self::xlsCell($row_number, $column_number);
if (!is_scalar($value) || $value==='') { //objects, array, empty
@@ -385,6 +402,8 @@ protected function writeCell(XLSXWriter_BuffererWriter &$file, $row_number, $col
$file->write(''.self::xmlspecialchars($value).'');
}
}
+
+ if (PHP_MAJOR_VERSION < 8) setlocale(LC_NUMERIC, $oldlocale);
}
protected function styleFontIndexes()