|
|
@@ -51,22 +51,16 @@ class CsController extends BaseController
|
|
|
$currentDirectory = getcwd();
|
|
|
|
|
|
require_once($phpExcelFile . 'Classes/PHPExcel/IOFactory.php');
|
|
|
- $objPHPExcel = \PHPExcel_IOFactory::load($currentDirectory . "/123.xlsx");
|
|
|
+ $spreadsheet = \PHPExcel_IOFactory::load($currentDirectory . "/123.xlsx");
|
|
|
|
|
|
//print_r($objPHPExcel->getActiveSheet()->toArray());
|
|
|
|
|
|
- echo 'Custom Properties:';
|
|
|
- $customProperties = $objPHPExcel->getProperties()->getCustomProperties();
|
|
|
- foreach($customProperties as $customProperty) {
|
|
|
- $propertyValue = $objPHPExcel->getProperties()->getCustomPropertyValue($customProperty);
|
|
|
- $propertyType = $objPHPExcel->getProperties()->getCustomPropertyType($customProperty);
|
|
|
- echo ' ' , $customProperty , ' - (' , $propertyType , ') - ';
|
|
|
- if ($propertyType == \PHPExcel_DocumentProperties::PROPERTY_TYPE_DATE) {
|
|
|
- echo date('d-M-Y H:i:s',$propertyValue);
|
|
|
- } elseif ($propertyType == \PHPExcel_DocumentProperties::PROPERTY_TYPE_BOOLEAN) {
|
|
|
- echo $propertyValue;
|
|
|
- } else {
|
|
|
- echo $propertyValue;
|
|
|
+ foreach ($spreadsheet->getActiveSheet()->getRowIterator() as $row) {
|
|
|
+ foreach ($row->getCellIterator() as $cell) {
|
|
|
+ if (!$cell->getValue()) { // 跳过空白单元格
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ echo 'Cell ' . $cell->getColumn() . $cell->getRow() . ' = ' . $cell->getValue() . '<br />';
|
|
|
}
|
|
|
}
|
|
|
|