代码语言:javascript复制
<?php
require "F:/6/htdocs/PHPExcel-1.8/Classes/PHPExcel/IOFactory.php";
$filename="F:/6/htdocs/PHPExcel-1.8/Classes/demo.slsx";
//引入读取的excel类文件
$objPHPExcel=PHPExcel_IOFactory::load($filename);
//加载要读取的文件
$sheetCount=$objPHPExcel->getSheetCount();
//获取excel文件中有多少个sheet
/*for ($i=0;$i<$sheetCount;$i )
{
$data=$objPHPExcel->getSheet($i)->toArray();
print_r($data);//读取每个sheet里的数据全部放到数组中.
}*/
foreach ($objPHPExcel->getWorksheetIterator() as $sheet)//循环取shert
{
foreach ($sheet->getRowIterator() as $row)//逐行处理
{
if($row->getRowIndex()<2)
{
continue;
}
foreach ($row->getCellIterator() as $cell)//逐列处理
{
$data=$cell->getValue();//获取单元格数据
echo $data." ";
}
echo "<br />";
}
echo "<br />";
}
exit;
?>