Skip to content

Commit 4fe3d4c

Browse files
committed
Fix numeric value detection for leading zeroes.
1 parent ffb1012 commit 4fe3d4c

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/Jobs/DataTableExportJob.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public function handle()
9494
? (new StyleBuilder)->setFormat($column['exportFormat'])->build()
9595
: null;
9696

97-
$value = is_numeric($value) ? (float) $value : $value;
97+
$value = $this->isNumeric($value) ? (float) $value : $value;
9898

9999
$cells->push(WriterEntityFactory::createCell($value, $format));
100100
}
@@ -117,4 +117,18 @@ protected function wantsDateFormat(Column $column): bool
117117

118118
return in_array($column['exportFormat'], config('datatables-export.date_formats', []));
119119
}
120+
121+
/**
122+
* @param mixed $value
123+
* @return bool
124+
*/
125+
protected function isNumeric($value): bool
126+
{
127+
// Skip numeric style if value has leading zeroes.
128+
if (Str::startsWith($value, '0')) {
129+
return false;
130+
}
131+
132+
return is_numeric($value);
133+
}
120134
}

0 commit comments

Comments
 (0)