weiphp 2.0:Your requested sheet index: 1 is out of bounds. The actual number of sheets is 0

网友投稿 1016 2022-11-08

weiphp 2.0:Your requested sheet index: 1 is out of bounds. The actual number of sheets is 0

weiphp 2.0:Your requested sheet index: 1 is out of bounds. The actual number of sheets is 0

Your requested sheet index: 1 is out of bounds. The actual number of sheets is 0

产生错误的原因是你可能打开了错误的文件,需要查一下你打开的文件是不是excel格式,还是哪里写错了。

我这里就是把file_id弄错了,导致它找不到我打开的文件,所以报了错误。

Vendor('PHPExcel/IOFactory'); Vendor('PHPExcel/Cell'); //判断excel版本,导入不同文件 $file_id=$message['filename']; //当时file_id没有用这条语句获取,所以下面getSheet的时候,就找不到我对应的文件,而打开了错误的文件 $file= M('file')->where('id='.$file_id)->find(); if ($file['ext'] == 'xls') { //如果excel文件后缀名为.xls,导入这个类 $objReader=\PHPExcel_IOFactory::createReader('Excel5'); } else { //如果excel文件后缀名为.xlsx,导入这个类 $objReader=\PHPExcel_IOFactory::createReader('Excel2007'); } $fileURL='./Uploads/Download/'.$file['savepath'].$file['savename']; //$this->success ($fileURL); // 判断使用哪种格式 //$objReader = PHPExcel_IOFactory::createReader("Excel2007"); $PHPExcel = $objReader ->load($fileURL); //$this->success ($PHPExcel); //获取表中的第一个工作表,如果要获取第二个,把0改为1,依次类推 $currentSheet = $PHPExcel->getSheet(0); $allColumn = $currentSheet->getHighestColumn(); //获取总列数 //$this->success ($allColumn); $allRow = $currentSheet->getHighestRow(); //获取总行数

参考文献

[1].PHPExcel_Exception' with message 'Your requested sheet index: 0 is out of bounds. The actual number of sheets is 0. https://github.com/Maatwebsite/Laravel-Excel/issues/678

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:Docker与CI持续集成/CDDocker与CI持续集成/CD
下一篇:AttributeError: ‘VotingClassifier‘ object has no attribute ‘set_criterion‘
相关文章

 发表评论

暂时没有评论,来抢沙发吧~