laravel Maatwebsite excel 导出数字转为

2021-03-31  本文已影响0人  归尘_7cc2

<?php

namespace App\Exports;

use Maatwebsite\Excel\Concerns\FromArray;

use Maatwebsite\Excel\Concerns\WithColumnFormatting;

use PhpOffice\PhpSpreadsheet\Style\NumberFormat;

class InvoicesExport implements FromArray, WithColumnFormatting

{

    protected $invoices;

    public function __construct(array $invoices)

    {

        $this->invoices = $invoices;

    }

    function array(): array

    {

        return $this->invoices;

    }

    public function columnFormats(): array

    {

        return [

            'A' => NumberFormat::FORMAT_NUMBER_COMMA_SEPARATED2,

            'B' => NumberFormat::FORMAT_NUMBER_COMMA_SEPARATED2,

            'C' => NumberFormat::FORMAT_NUMBER_COMMA_SEPARATED2,

            'D' => NumberFormat::FORMAT_NUMBER_COMMA_SEPARATED2,

            'E' => NumberFormat::FORMAT_NUMBER_COMMA_SEPARATED2,

            'F' => NumberFormat::FORMAT_NUMBER_COMMA_SEPARATED2,

            'G' => NumberFormat::FORMAT_NUMBER_COMMA_SEPARATED2,

            'H' => NumberFormat::FORMAT_NUMBER_COMMA_SEPARATED2,

            'I' => NumberFormat::FORMAT_NUMBER_COMMA_SEPARATED2,

            'J' => NumberFormat::FORMAT_NUMBER_COMMA_SEPARATED2,

            'K' => NumberFormat::FORMAT_NUMBER_COMMA_SEPARATED2,

            'L' => NumberFormat::FORMAT_NUMBER_COMMA_SEPARATED2,

            'M' => NumberFormat::FORMAT_NUMBER_COMMA_SEPARATED2,

            'N' => NumberFormat::FORMAT_NUMBER_COMMA_SEPARATED2,

            'O' => NumberFormat::FORMAT_NUMBER_COMMA_SEPARATED2,

            'P' => NumberFormat::FORMAT_NUMBER_COMMA_SEPARATED2,

            'Q' => NumberFormat::FORMAT_NUMBER_COMMA_SEPARATED2,

            'R' => NumberFormat::FORMAT_NUMBER_COMMA_SEPARATED2,

            'S' => NumberFormat::FORMAT_NUMBER_COMMA_SEPARATED2,

            'T' => NumberFormat::FORMAT_NUMBER_COMMA_SEPARATED2,

            'U' => NumberFormat::FORMAT_NUMBER_COMMA_SEPARATED2,

            'V' => NumberFormat::FORMAT_NUMBER_COMMA_SEPARATED2,

            'W' => NumberFormat::FORMAT_NUMBER_COMMA_SEPARATED2,

            'X' => NumberFormat::FORMAT_NUMBER_COMMA_SEPARATED2,

            'Y' => NumberFormat::FORMAT_NUMBER_COMMA_SEPARATED2,

            'Z' => NumberFormat::FORMAT_NUMBER_COMMA_SEPARATED2,

        ];

    }

}

上一篇下一篇

猜你喜欢

热点阅读