zoukankan      html  css  js  c++  java
  • php-xlswriter Excel操作

    function write($filename)
        {
            $config = ['path' => '/code/logs/'];
            $excel = new VtifulKernelExcel($config);
            $header = [
                '订单号',
                '业务类型',
                '公司id',
                '贷款银行',
                '贷款银行名字',
                '进单时间',
            ];
    
            $filePath = $excel->constMemory($filename)
                ->header($header);
            $bar = $this->output->createProgressBar(Trade::count('id') / 2000);
            $bar->setFormat("   %elapsed:6s%/%estimated:-6s%   内存消耗: %memory:6s%
    %current%/%max% [%bar%] %percent:3s%%");
    
    //        // 读取测试文件
    //        $data = $excel->openFile('tutorial.xlsx')
    //            ->openSheet();
    //        $d = [];
    //        while ($row = $excel->nextRow()) {
    //            $this->info(json_encode($row, JSON_UNESCAPED_UNICODE));
    //            $bar->advance();
    //            $d[] = $row;
    //        }
    //        $bar->finish();
            Trade::orderBy('created_at')->chunk(2000, function ($trades) use ($filePath, $bar) {
                foreach ($trades as $trade) {
                    $data[] = [
                        $trade->id,
                        $trade->product_type,
                        $trade->company_id,
                        $trade->admin_user_id,
                        $trade->loan_bank_code,
                        $trade->loan_bank_name,
                        $trade->created_at,
                    ];
                }
                $filePath->data($data);
                $bar->advance();
            });
            $bar->finish();
            $filePath->output();
        }
    
  • 相关阅读:
    请说出这些测试最好由那些人员完成,测试的是什么?
    测试结束的标准是什么?
    你的测试职业发展目标是什么?
    elementui医疗
    医疗前端
    spring创建对象3种方式
    idea-git
    eclipse-git
    ArrayList01
    单体权限
  • 原文地址:https://www.cnblogs.com/shiwenhu/p/12655708.html
Copyright © 2011-2022 走看看