yajra / laravel-datatables-buttons

Laravel DataTables Buttons Plugin
https://yajrabox.com/docs/laravel-datatables/buttons-installation
MIT License
254 stars 53 forks source link

Keep original type in exportable array #63

Closed FabienLucini closed 6 years ago

FabienLucini commented 6 years ago

https://github.com/yajra/laravel-datatables-buttons/blob/cdf7df773461900791491b1855397b099230b1f8/src/Transformers/DataArrayTransformer.php#L42

Hi, it seems that you are always returning strings here, but if we want an excel sheet to be correctly formatted with numbers for example, we should return the original variable type.

You could do this for example :

if ($type == 'exportable') {
    $dataType = gettype($data);
    $data     = $this->decodeContent($data);
    settype($data, $dataType);

    $title    = $this->decodeContent($title);
}
yajra commented 6 years ago

@FabienLucini sorry for late response, can you submit a PR on your proposed solution? Thanks!