PHP code example of sunmoon / yii2-phpspreadsheet
1. Go to this page and download the library: Download sunmoon/yii2-phpspreadsheet library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
sunmoon / yii2-phpspreadsheet example snippets
use sunmoon\phpspreadsheet\Excel as ExcelHelper;
public function actionReadExcel(){
$fileName = 'demo.xlsx';
//从第1行读取到第7行
$data = ExcelHelper::import($fileName, ['readStartRow'=>1, 'readEndRow'=>7, ]);
return $data;
}
use sunmoon\phpspreadsheet\Excel as ExcelHelper;
public function actionReadExcelRows(){
$fileName = 'demo.xlsx';
$data = ExcelHelper::getHighestRows($fileName);
return $data;
}