Laravel-Excel2.1 导出:Uninitialized string offset: 1

###保存提示行数内容

//echo 'Initial character of expression block is '.$opCharacter, PHP_EOL;
  if ((isset(self::$comparisonOperators[$opCharacter])) && (strlen($formula) > $index) && (isset(self::$comparisonOperators[$formula{$index+1}]))) {
  $opCharacter .= $formula{++$index};
//echo 'Initial character of expression block is comparison operator '.$opCharacter.PHP_EOL;
  }

laravel-excel2.1 导出:Uninitialized string offset: 1

$date = date('ymdHis');
        //创建文件
        $fileName = 'single_result'.$date;
        $format = 'csv';

        $alias = '匹配结果'.$date.'.xls';
        Excel::create($fileName,function($excel) {
            //创建工作表
            $excel->sheet('score', function($sheet) {

                $sheet->setColumnFormat(array(
                    'D' => '@',
                    'G' => '@',
                    'H' => '@',
                    'L' => '@',
                    'N' => '@'
                ));

                //分块获取数据
                OwcpMatchresult::with([
                    'user' 
                    'cp' ,
                ])->where('type','single_normal')->orderBy('managerid')->chunk(300, function ($result) use($sheet) {
                //单身异性 single_normal   单身同性single_homosex
                    $list = $result->toArray();
                    $data =[];
                    foreach($list as $key => $user)
                    {
                        $room = [
                                $user['managerid'],
                                $user['num'],
                            ];
                        if($user['user'])
                        {
                            $data []= array_merge($room,$user['user']);


                        }else{
                            $data[] = $room;
                        }
                        if($user['cp'])
                        {
                            $data []= array_merge($room,$user['cp']);
                        }else{
                            $data[] = $room;
                        }
                    }
                    //多行追加
                    $sheet->rows($data);
                });
            });
        })->store($format);

导出数量少时并没有问题,想知道数量多的情况下有什么需要注意修改的地方吗?
已经这个问题有没有大佬帮忙看下怎么解决才好

《L04 微信小程序从零到发布》
从小程序个人账户申请开始,带你一步步进行开发一个微信小程序,直到提交微信控制台上线发布。
《L02 从零构建论坛系统》
以构建论坛项目 LaraBBS 为线索,展开对 Laravel 框架的全面学习。应用程序架构思路贴近 Laravel 框架的设计哲学。
最佳答案

用户昵称存在表情或个别符合导致生成csv文件失败,目前先过滤所有符号

$regex = "/\/|\~|\!|\@|\#|\\$|\%|\^|\&|\*|\(|\)|\_|\+|\{|\}|\:|\<|\>|\?|\[|\]|\,|\.|\/|\;|\'|\`|\-|\=|\\\|\|/";
$str  = preg_replace($regex,"",$str);
4年前 评论
讨论数量: 1

用户昵称存在表情或个别符合导致生成csv文件失败,目前先过滤所有符号

$regex = "/\/|\~|\!|\@|\#|\\$|\%|\^|\&|\*|\(|\)|\_|\+|\{|\}|\:|\<|\>|\?|\[|\]|\,|\.|\/|\;|\'|\`|\-|\=|\\\|\|/";
$str  = preg_replace($regex,"",$str);
4年前 评论

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!