phpexcel读取excel2007
原创
©著作权归作者所有:来自51CTO博客作者黄啊码_51CTO的原创作品,请联系作者获取转载授权,否则将追究法律责任
注:phpexcel无法读取包含图片的excel,如果读取会报编码错误
header("content-Type: text/html; charset=UTF-8");
error_reporting(E_ALL);
require 'include/PHPExcel/Classes/PHPExcel.php';
require 'include/PHPExcel/Classes/PHPExcel/Reader/Excel2007.php';
$excel_file = '2007.xlsx';
$PHPExcel = new PHPExcel();
$PHPReader = new PHPExcel_Reader_Excel2007(); //还有这句
$PHPExcel = $PHPReader->load($excel_file);
$sheet = $PHPExcel->getActiveSheet();
$allCol=PHPExcel_Cell::columnIndexFromString($sheet->getHighestColumn());
$allRow=$sheet->getHighestRow();
for($col=1; $col<=$allCol;$col++)
{
for ($row=0;$row<$allRow;$row++)
{
echo $sheet->getCellByColumnAndRow($row,$col)->getValue()." ";
}
echo "<br/>";