php 获取xlsx,PHPExcel获取.xlsx文件内容
include ‘/home/www/PHPExcel/Classes/PHPExcel.php‘;
include ‘/home/www/PHPExcel/Classes/PHPExcel/IOFactory.php‘;
$obj = PHPExcel_IOFactory::load(‘/home/www/a.xlsx‘);
/*echo ‘
‘;var_dump($obj);
echo ‘
‘;*/$sheet = $obj->getSheet(0);
//行數(shù)
$hight = $sheet->getHighestRow();
//列數(shù)
$column = $sheet->getHighestColumn();
//轉(zhuǎn)換列數(shù)
$column=PHPExcel_Cell::columnIndexFromString($column);
$a=PHPExcel_Cell::stringFromColumnIndex(0);
$b=$sheet->getCell($a.‘1‘)->getValue();
//$b=PHPExcel_Cell::stringFromColumnIndex(‘A‘);
$array=[];
for($i=0; $i
$numberName=PHPExcel_Cell::stringFromColumnIndex($i).‘1‘;
$keyName=$sheet->getCell($numberName)->getValue();
array_push($array, $keyName);
}
$price=[];
for ($i=2 ;$i
for($j=0;$j
$numberName=PHPExcel_Cell::stringFromColumnIndex($j).$i;
$keyName=$sheet->getCell($numberName)->getValue();
$row[$array[$j]]=$keyName;
}
$price[]=$row;
}
echo ‘
‘;var_dump($price);
echo ‘
‘;原文:http://www.cnblogs.com/lpdi/p/6728043.html
總結(jié)
以上是生活随笔為你收集整理的php 获取xlsx,PHPExcel获取.xlsx文件内容的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: php设置文件权限问题,关于.user.
- 下一篇: java中如果写设置密码,在java中编