phpexcellaravelmaatwebsite-excel

laravel maatwebsite excel export currency row


Im using the laravel maatwebsite package to export an excel sheet. One column contains euro currency, so im trying to make a currency column for the data.

my code for the columns:

    $sheet->setColumnFormat(array(
        'G' =>  \PHPExcel_Style_NumberFormat::FORMAT_NUMBER_00,
        'H' =>  "[$EUR ]#,##0.00_-",
        'I' =>  \PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_EUR_SIMPLE,
    ));

with no luck, when for example 5 (without any decimals) is inserted in one of these columns the data looks like 5 instead of € 5.00

How is the formating set in the correct way?


Solution

  • You can add data-format attribute to<td>
    Example:

    <td data-format="$#,##0_-">Price</td>
    <td data-format="0.00">Price</td>
    <td data-format="0%">Percentage</td>
    <td data-format="dd/mm/yy">Date</td>
    <td data-format="h:mm:ss AM/PM">Date/Time</td>