美文网首页
laravel Maatwebsite excel 导出数字转为

laravel Maatwebsite excel 导出数字转为

作者: 归尘_7cc2 | 来源:发表于2021-03-31 17:06 被阅读0次

    <?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,

            ];

        }

    }

    相关文章

      网友评论

          本文标题:laravel Maatwebsite excel 导出数字转为

          本文链接:https://www.haomeiwen.com/subject/xjkahltx.html