add contraint , that everybody expect admin is limited to 3 days, Add card package
This commit is contained in:
44
common/components/XLSUtil.php
Normal file
44
common/components/XLSUtil.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace common\components;
|
||||
|
||||
class XLSUtil {
|
||||
|
||||
public $objPHPExcel;
|
||||
|
||||
public function loadFromFileName($inputFileName) {
|
||||
// Read your Excel workbook
|
||||
try {
|
||||
$inputFileType = \PHPExcel_IOFactory::identify ( $inputFileName );
|
||||
$objReader = \PHPExcel_IOFactory::createReader ( $inputFileType );
|
||||
$this->objPHPExcel = $objReader->load ( $inputFileName );
|
||||
echo "type is: " . $inputFileType;
|
||||
} catch ( Exception $e ) {
|
||||
\Yii::error ( "failed to read xls" );
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* first sheet to array
|
||||
*/
|
||||
public function toArray( ) {
|
||||
$objPHPExcel = $this->objPHPExcel;
|
||||
$array = [ ];
|
||||
// Get worksheet dimensions
|
||||
$sheet = $objPHPExcel->getActiveSheet();
|
||||
//$highestColumn = $sheet->getHighestColumn();
|
||||
$hr = $sheet->getHighestRow();
|
||||
foreach ( $sheet->getRowIterator () as $row ) {
|
||||
$arrayRow = [];
|
||||
$cellIterator = $row->getCellIterator ();
|
||||
$cellIterator->setIterateOnlyExistingCells ( false ); // Loop all cells, even if it is not set
|
||||
foreach ( $cellIterator as $cell ) {
|
||||
$arrayRow [] = $cell->getCalculatedValue();
|
||||
}
|
||||
$array[] = $arrayRow;
|
||||
}
|
||||
|
||||
return $array;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user