最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
php导入excel经典实例
时间:2022-06-24 19:06:56 编辑:袖梨 来源:一聚教程网
require_once 'excel/reader.php';
// excelfile($filename, $encoding);
$data = new spreadsheet_excel_reader();
// set output encoding.
$data->setoutputencoding('cp1251');
$data->read('jxlrwtest.xls');
error_reporting(e_all ^ e_notice);
for ($i = 1; $i sheets[0]['numrows']; $i++) {
for ($j = 1; $j sheets[0]['numcols']; $j++) {
echo """.$data->sheets[0]['cells'][$i][$j]."",";
}
echo " ";
}
格式化输出格式
/***
* some function for formatting output.
* $data->setdefaultformat('%.2f');
* setdefaultformat - set format for columns with unknown formatting
*
* $data->setcolumnformat(4, '%.3f');
* setcolumnformat - set format for column (apply only to number fields)
*
**/
统计总行数与按列名输出。
$data->sheets[0]['numrows'] - count rows
$data->sheets[0]['numcols'] - count columns
$data->sheets[0]['cells'][$i][$j] - data from $i-row $j-column
$data->sheets[0]['cellsinfo'][$i][$j] - extended info about cell
$data->sheets[0]['cellsinfo'][$i][$j]['type'] = "date" | "number" | "unknown"
if 'type' == "unknown" - use 'raw' value, because cell contain value with format '0.00';
$data->sheets[0]['cellsinfo'][$i][$j]['raw'] = value if cell without format
$data->sheets[0]['cellsinfo'][$i][$j]['colspan']
$data->sheets[0]['cellsinfo'][$i][$j]['rowspan']
相关文章
- 地下城堡4骨语蕾妮塔怎么样 骨语蕾妮塔角色介绍一览 09-16
- 地下城堡4白骑士怎么玩 白骑士玩法介绍 09-16
- 三国望神州吕玲绮怎么培养 吕玲绮养成技巧 09-16
- 洛伊的移动要塞橡果怎么获得 橡果获取方法 09-16
- 龙族卡塞尔之门七原罪傲慢技能是什么 七原罪傲慢技能介绍 09-16
- 三国望神州巨野夺城战怎么打 巨野夺城战打法教学 09-16