PHP读取excel文件
require("Classes/PHPExcel.php");
require("Classes/PHPExcel/IOFactory.php");
require("Classes/PHPExcel/Reader/Excel5.php");
require("Classes/PHPExcel/Reader/Excel2007.php");
$filePath = "text.xls" ;
$PHPExcel = new PHPExcel() ;
$PHPReader = new PHPExcel_Reader_Excel2007(); if(!$PHPReader->canRead($filePath)){
$PHPReader = new PHPExcel_Reader_Excel5();
if(!$PHPReader->canRead($filePath)){
return false;
}
} //读取excel
$PHPExcel = $PHPReader->load($filePath); //获取工作表的数目
$sheetCount = $PHPExcel->getSheetCount(); $sheet = 0 ;
$currentSheet = $PHPExcel->getSheet($sheet);
$allRow = $currentSheet->getHighestRow(); //获取Excel中信息的行数
$allColumn = $currentSheet->getHighestColumn();//获取Excel的列数 $objWorksheet = $PHPExcel->getActiveSheet();
$highestRow = $objWorksheet->getHighestRow(); //有效总行数 $highestColumnIndex = $objWorksheet->getHighestColumn();
$highestColumn = PHPExcel_Cell::columnIndexFromString($highestColumnIndex);//有效总列数 //获取表格值
$data = $objWorksheet->getCellByColumnAndRow($col, $row)->getValue() ;