Skip to content

Commit

Permalink
auto-detect unknown column types (ie missing header def for last column)
Browse files Browse the repository at this point in the history
  • Loading branch information
mk-j committed Feb 2, 2017
1 parent 53842b9 commit 218144c
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions xlsxwriter.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -302,15 +302,12 @@ protected function writeCell(XLSXWriter_BuffererWriter &$file, $row_number, $col
$file->write('<c r="'.$cell_name.'" s="'.$cell_style_idx.'" t="n"><v>'.self::xmlspecialchars($value).'</v></c>');//int,float,currency
} 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') {
} 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)){
$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>');
}
} else {
$file->write('<c r="'.$cell_name.'" s="'.$cell_style_idx.'"/>');
trigger_error("Unknown column type: ".$num_format_type, E_USER_ERROR);
}
}

Expand Down

0 comments on commit 218144c

Please sign in to comment.