PHP import excel classic example_PHP tutorial

WBOY
Release: 2016-07-13 17:05:08
Original
1008 people have browsed it

php tutorial import excel classic example

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 <= $data->sheets[0]['numrows']; $i++) {
for ($j = 1; $j <= $data->sheets[0]['numcols']; $j++) {
echo """.$data->sheets[0]['cells'][$i][$j]."",";
}
echo "n";

}

Format output format

/***
*  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)
*
**/

Count the total number of rows and output by column name.
$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 tutorial import excel classic example require_once 'excel/reader.php'; // excelfile($filename, $encoding ); $data = new spreadsheet_excel_reader(); // set output encoding. $data-setoutpu...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!