yajra / laravel-datatables

jQuery DataTables API for Laravel
https://yajrabox.com/docs/laravel-datatables
MIT License
4.75k stars 861 forks source link

Currency shows strange characters when viewed using MS excel #3177

Open jonjieviduya opened 4 days ago

jonjieviduya commented 4 days ago

Summary of problem or feature request

When viewing the exported file, the Philippine Peso (₱) currency shows strange characters: â,±. I tried both ₱ and the but both of these are not working and still show the same strange characters.

Code snippet of problem

->addColumn('Order Amount', function ($payment) {
    return '₱' . number_format((float) $payment->amount, 2);
})

System details

yajra commented 4 days ago

You might need to add Order Amount to the raw columns.

Or you can use the render option via js to handle the money formatting.

yajra commented 4 days ago

Oh, the context was on export ~~ I will have to review this one. I think the formatting should be handled on the Excel cell format level for this to work.

yajra commented 4 days ago

There are new features released via https://github.com/yajra/laravel-datatables-buttons/pull/186 and https://github.com/yajra/laravel-datatables-buttons/pull/187. That might help in your case.

jonjieviduya commented 3 days ago

@yajra yes it is for export. Using these links, how can I format the currency? BTW it is working when you open it using google sheet. The issue only occurs when opening in ms excel.

There are new features released via yajra/laravel-datatables-buttons#186 and yajra/laravel-datatables-buttons#187. That might help in your case.

yajra commented 3 days ago

Try using exportFormat('₱#,##0.00'). This is how I usually check Excel.

image