mirror of
https://github.com/shuchkin/simplexlsxgen.git
synced 2023-08-10 21:12:59 +03:00
Added PHP Datetime object values in a cells
This commit is contained in:
@ -351,9 +351,6 @@ class SimpleXLSXGen {
|
||||
if ( $v === null || $v === '' ) {
|
||||
continue;
|
||||
}
|
||||
$vl = mb_strlen( (string) $v );
|
||||
|
||||
$COL[ $CUR_COL ] = max( $vl, $COL[ $CUR_COL ] );
|
||||
|
||||
$cname = $this->num2name($CUR_COL) . $CUR_ROW;
|
||||
|
||||
@ -361,6 +358,8 @@ class SimpleXLSXGen {
|
||||
|
||||
if ( is_string($v) ) {
|
||||
|
||||
$vl = mb_strlen( $v );
|
||||
|
||||
if ( $v === '0' || preg_match( '/^[-+]?[1-9]\d{0,14}$/', $v ) ) { // Integer as General
|
||||
$cv = ltrim( $v, '+' );
|
||||
if ( $vl > 10 ) {
|
||||
@ -412,13 +411,21 @@ class SimpleXLSXGen {
|
||||
}
|
||||
}
|
||||
} elseif ( is_int( $v ) ) {
|
||||
$vl = mb_strlen( (string) $v );
|
||||
$cv = $v;
|
||||
} elseif ( is_float( $v ) ) {
|
||||
$vl = mb_strlen( (string) $v );
|
||||
$cv = $v;
|
||||
} elseif ( $v instanceof DateTime ) {
|
||||
$vl = 16;
|
||||
$cv = $this->date2excel( $v->format('Y'), $v->format('m'), $v->format('d'), $v->format('H'), $v->format('i'), $v->format('s') );
|
||||
$cs = 6; // [22] m/d/yy h:mm
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
|
||||
$COL[ $CUR_COL ] = max( $vl, $COL[ $CUR_COL ] );
|
||||
|
||||
$row .= '<c r="' . $cname . '"'.($ct ? ' t="'.$ct.'"' : '').($cs ? ' s="'.$cs.'"' : '').'>'
|
||||
.($ct === 'inlineStr' ? '<is><t>'.$cv.'</t></is>' : '<v>' . $cv . '</v>')."</c>\r\n";
|
||||
}
|
||||
|
Reference in New Issue
Block a user