Home > php教程 > php手册 > php Spreadsheet_Excel_Reader读取excel文件

php Spreadsheet_Excel_Reader读取excel文件

WBOY
Release: 2016-05-26 15:21:57
Original
2555 people have browsed it

本文章主要是讲利用spreadsheet_excel_reader读取 excel文件,在你网站数据量超大的时候或有很多会员数据时这个是有必要把当日数据导入到excel备份的,为此我们提供一款读取excel文件实例.

使用本实例需要先下载一个spreadsheet_excel_reader类.

PHP实例代码如下:

$reader=new spreadsheet_excel_reader(); 
$reader->setutfencoder('iconv'); 
$reader->setoutputencoding('utf-8'); //可以设置的文档编码 
$reader->read($filename); 
//如果以以表格形式输出我们就利用遍历 
foreach ($reader->boundsheets as $k=>$sheet) 
{ 
    echo "n$k: $sheet"; 
} 
//表中的数据存储在表变量.每一个表是一个二维数组。以下是如何打印所有数据 
foreach($reader->sheets as $k=>$data) 
{
    echo "nn ".$reader->boundsheets[$k]."nn"; 
    foreach($data['cells'] as $row) 
    { 
        foreach($row as $cell) 
        { 
            echo "$cellt"; 
        } 
        echo "n"; 
    } 
}
Copy after login


本文地址:

转载随意,但请附上文章地址:-)

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 Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template