diff --git a/xlsxwriter.class.php b/xlsxwriter.class.php index 81bc7589d..cc8c15112 100644 --- a/xlsxwriter.class.php +++ b/xlsxwriter.class.php @@ -369,7 +369,11 @@ protected function writeCell(XLSXWriter_BuffererWriter &$file, $row_number, $col } elseif ($num_format_type=='n_datetime') { $file->write(''.self::convert_date_time($value).''); } elseif ($num_format_type=='n_numeric') { - $file->write(''.self::xmlspecialchars($value).'');//int,float,currency + if (!is_string($value) || $value=='0' || ($value[0]!='0' && ctype_digit($value)) || preg_match("/^\-?(0|[1-9][0-9]*)?(\.[0-9]+)?$/", $value)){ + $file->write(''.self::xmlspecialchars($value).'');//int,float,currency + } else { //not numeric, treat it as string + $file->write(''.self::xmlspecialchars($value).''); + } } elseif ($num_format_type=='n_string') { $file->write(''.self::xmlspecialchars($value).''); } elseif ($num_format_type=='n_auto' || 1) { //auto-detect unknown column types