Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
445 views
in Technique[技术] by (71.8m points)

php - read xls with Maatwebsite

i′m traying to read all content from xls with library maatwebsite in laravel 5.8, but always returned me this message: pathinfo() expects parameter 1 to be string, object given and i don′t know that i′m doing wrong. I readed documentation and i showed many examples. i have version maatwebsite that haven′t got method load() my version have import() and i need read all content of my file and after i will select that column i want to import. My actual code is:

public function showDataFileView(Request $request)
    {
        $path = storage_path('app/public/710/FileExchangeBaseTemplate.xls');
        
        Excel::import($path, function($reader){
            $result = $reader->get();
            dd($result);
        });

        return View::make('restaurants.viewfileupload');
    }

always returned me pathinfo() expects parameter 1 to be string, object given

UPDATE

i got read my headers with this:

** El método load permite cargar el archivo definido como primer parámetro */
$path = storage_path('app/public/718/').$request->get("file");

//Excel::import(new ExcelImport, $request->get("file"));
$data = Excel::toArray([], $path);


       $header = array(
           'data' => $data[0][0]
       );

   return View::make('restaurants.viewfileupload')->with("prueba", $header["data"]);

now i′m traying to get body of my file.

Thanks for help


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...