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);

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

《L03 构架 API 服务器》
你将学到如 RESTFul 设计风格、PostMan 的使用、OAuth 流程,JWT 概念及使用 和 API 开发相关的进阶知识。
《G01 Go 实战入门》
从零开始带你一步步开发一个 Go 博客项目,让你在最短的时间内学会使用 Go 进行编码。项目结构很大程度上参考了 Laravel。
最佳答案

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

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

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

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

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