Php 如何读取excel文件并在Yii 2中显示数据?

Php 如何读取excel文件并在Yii 2中显示数据?,php,phpexcel,yii2,yii-extensions,yii-components,Php,Phpexcel,Yii2,Yii Extensions,Yii Components,我尝试使用PHPExcel库读取excel文件并显示文件中的数据。但这对我不起作用 我也尝试过使用扩展和其他一些方法,但没有任何效果。我希望能得到专家人员的帮助 我曾在CakePHP中使用PHPExcel从excel中读取数据,但我不知道如何使代码在Yii 2中可行。如何在Yii2中加载PHPExcel?我正在使用XLSX。在CakePHP中,我可以使用- App::import('Vendor', 'Excel/reader'); $data = new Spreadsheet_Excel_

我尝试使用PHPExcel库读取excel文件并显示文件中的数据。但这对我不起作用

我也尝试过使用扩展和其他一些方法,但没有任何效果。我希望能得到专家人员的帮助

我曾在CakePHP中使用PHPExcel从excel中读取数据,但我不知道如何使代码在Yii 2中可行。如何在Yii2中加载PHPExcel?我正在使用XLSX。在CakePHP中,我可以使用-

App::import('Vendor', 'Excel/reader'); 
$data = new Spreadsheet_Excel_Reader();
$data->setOutputEncoding('CP1251');
$data->read(WWW_ROOT . 'uploads/' . $_FILES["filename"]["name"]);
$cells = $data->sheets[0]['cells'];
提前谢谢

使用composer安装扩展:

composer require phpoffice/phpexcel
在你看来:

$objPHPExcel = \PHPExcel_IOFactory::load('./test.xlsx');
$sheetData = $objPHPExcel->getActiveSheet()->toArray(null, true, true, true);
print_r($sheetData);

按照Christian Lescuyer的指示,我安装了composer依赖项。但是我必须编辑一个依赖文件

在文件vendor\phpoffice\phpexcel\Classes\phpexcel\Shared\OLE.php中,第288行
我必须删除“continue;”并在其位置添加“break;”。

文件的大致结构、扩展名和大小是多少?请添加更多详细信息。展示你的尝试,我知道了。结果从1开始,而不是从0开始<代码>echo($sheetData[1][“B”])此回购已被弃用,取而代之的是我