Skip to content

Commit

Permalink
adjust decimal matching regex to match 0.05
Browse files Browse the repository at this point in the history
  • Loading branch information
mk-j committed Jan 11, 2018
1 parent e7e5ada commit 8d09a74
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion xlsxwriter.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ protected function writeCell(XLSXWriter_BuffererWriter &$file, $row_number, $col
} elseif ($num_format_type=='n_string') {
$file->write('<c r="'.$cell_name.'" s="'.$cell_style_idx.'" t="inlineStr"><is><t>'.self::xmlspecialchars($value).'</t></is></c>');
} elseif ($num_format_type=='n_auto' || 1) { //auto-detect unknown column types
if (!is_string($value) || $value=='0' || ($value[0]!='0' && ctype_digit($value)) || preg_match("/^\-?[1-9][0-9]*(\.[0-9]+)?$/", $value)){
if (!is_string($value) || $value=='0' || ($value[0]!='0' && ctype_digit($value)) || preg_match("/^\-?(0|[1-9][0-9]*)(\.[0-9]+)?$/", $value)){
$file->write('<c r="'.$cell_name.'" s="'.$cell_style_idx.'" t="n"><v>'.self::xmlspecialchars($value).'</v></c>');//int,float,currency
} else { //implied: ($cell_format=='string')
$file->write('<c r="'.$cell_name.'" s="'.$cell_style_idx.'" t="inlineStr"><is><t>'.self::xmlspecialchars($value).'</t></is></c>');
Expand Down

0 comments on commit 8d09a74

Please sign in to comment.