猿问

phpExcel打印数据问题

1.上传一个.xlsx文件,服务器端解析文件,用phpExcel读取excel中内容,打印其中内容,只显示了一行数据中的一个,其他都没有显示
2.html代码:
<form name="form1" id="form1">

     <p><input type="file" id="excelImport" value=""  name="excelImport"></p>
      <p><input type="button" name="b1" value="submit" onclick="fsubmit()" /></p>

</form>

js代码:
function fsubmit(){
    var form=document.getElementById("form1");
    var fd =new FormData(form);
    console.log(fd);
    $.ajax({
         url: "/module/library/control/batch_insert?_token={{csrf_token()}}",
         type: "POST",
         data: fd,
         processData: false,  // 告诉jQuery不要去处理发送的数据
         contentType: false,   // 告诉jQuery不要去设置Content-Type请求头
         success: function(response,status,xhr){
            console.log(response);
         }
    });
    return false;
}
php代码:
public function batch_insert()
{
    $file = $_FILES['excelImport']['tmp_name'];
    $file = iconv('UTF-8', 'GBK',$file);
    var_dump($file);
    \Excel::load($file, function($reader) {
        $data = $reader->toArray();
        var_dump($data);
    });
}

3.

https://img2.mukewang.com/5c8f5b8f0001920b08000058.jpg
4.只显示了人员照片1,其他的姓名啥的都没显示,不知道为啥。

喵喵时光机
浏览 606回答 3
3回答

侃侃尔雅

你需要在你封装好的phpexcel函数里面,把你要显示的变量传进去啊.
随时随地看视频慕课网APP
我要回答