php-php traversing an Excel document and outputting content

Source: Internet
Author: User
Keywords Php
Php

!--? php Header ("content-type:text/html;charset=gb2312");
//This is the excel_reader2.php package for the home of the download script! Baidu is under the!
require_once ' excel/excel_reader2.php ';
$dir = "wps/";//Store folder name
$handle =opendir ($dir. ".");//Open Directory
$row =array ();
while (false!== ($file = Readdir ( $handle))
{
if ($file! = "." && $file! = "...") {
$row []= $dir. $file;//output filename
//echo $file;
}
}
Closedir ($handle);//Close Open Directory
//print_r ($row);
$data = new Spreadsheet_excel_reader ();
$data->setoutputencoding (' GB2312 ');//Set Text output encoding
//Read Excel file
//The problem starts here, the following loops the Excel document, but the output is always the same!
//for ($k =0; $k $data->read ($row [0]);//This is the function inside the package, read the Excel document
//$data->sheets[0][' NumRows '] is the number of rows in Excel
for ($i = 1; $i <= $data->sheets[0][' numrows '); $i + +) {
}
//}
//$data->sheets[0][' NumRows '] is an array, to fetch the $ data->sheets[0][' NumRows '][2] the contents of each line (my table is a total of two rows, all the tables are the same!) The first behavior header, to read the contents of the second line, so 2), here after the loop, the array is always the same, the loop content is always the first read content! Ask the Master to recycle all the contents of the document!

print_r($data->sheets[0]['cells'][2]);

?>

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.