php导入excel经典实例_PHP教程

WBOY
發布: 2016-07-13 17:05:08
原創
964 人瀏覽過

php教程导入excel经典实例

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 "n";

}

格式化输出格式

/***
*  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']

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/630797.htmlTechArticlephp教程导入excel经典实例 require_once 'excel/reader.php'; // excelfile($filename, $encoding); $data = new spreadsheet_excel_reader(); // set output encoding. $data-setoutpu...
來源:php.cn
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!