借助PHP-ExcelReader这个开源类,我们可以轻松地导入Excel文件数据,示例代码如下:
<?php require_once 'Excel/reader.php'; $data = new Spreadsheet_Excel_Reader(); $data->setOutputEncoding('gbk'); $data->read('test.xls'); for ($i = 1; $i <= $data->sheets[0]['numRows']; $i++) { for ($j = 1; $j <= $data->sheets[0]['numCols']; $j++) { echo "\"".$data->sheets[0]['cells'][$i][$j]."\","; } echo "\n"; } ?>
PHP-ExcelReader下载地址:http://sourceforge.net/projects/phpexcelreader/