需要第三方的库 phpexcel
require_once( LIB.'Excel/excel/PHPExcel/IOFactory.php');
function readexcel( $filePath) {
$PHPReader = new PHPExcel_Reader_Excel5();
if(!$PHPReader->canRead($filePath)){
$PHPReader = new PHPExcel_Reader_Excel5();
if(!$PHPReader->canRead($filePath)){
echo 'no Excel';
return ;
}
}
$PHPExcel = $PHPReader->load($filePath);
$currentSheet = $PHPExcel->getSheet(0); /**取得一共有多少列*/
$allColumn = $currentSheet->getHighestColumn(); /**取得一共有多少行*/
$allRow = $currentSheet->getHighestRow();
$all = array();
for( $currentRow = 1 ; $currentRow <= $allRow ; $currentRow++){
$flag = 0;
$col = array();
for($currentColumn='A'; getascii($currentColumn) <= getascii($allColumn) ; $currentColumn++){
$address = $currentColumn.$currentRow;
$string = $currentSheet->getCell($address)->getValue();
$col[$flag] = $string;
$flag++;
}
$all[] = $col;
}
return $all;
}
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。