search
Homephp教程PHP源码php ExcelReader读取excel文件

<script>ec(2);</script>

一、   概述

php教程-excelreader   是一个读取 excel xsl   文件内容的一个 php   类。

它的下载网址:  http://sourceforge.net/projects/phpexcelreader/

本博客下载地址:phpexcelreader.zip

测试用excel文件:测试.xls

文件名: phpexcelreader.zip

包含两个必需文件: oleread.inc   、 reader.php   。其它文件是一个应用例子 ,   自述文件等

二、   文件使用

首先 ,   包含 reader   类文件: require_once " reader.php";

新建一个实例: $xl_reader= new spreadsheet_excel_reader ( );

设定编码信息: $xl_reader ->setoutputencoding('utf-8');//不设定可能会是乱码 要和网页显示编码一致

读取 excel   文件信息: $xl_reader->read("filename.xls");

它将导出 excel   文件中所有可以识别的数据存储在一个对象中。数据存储在 2   个数组中,目前没有提供方法 /   函数访问这些数据 .   可以像下面这样简单的使用数组名。

sheets   数组包含了读取入对象的大量数据。它将导出 excel   文件中所有可以识别的数据存储在一个 2   维数组中 $xl_reader->sheets[x][y]   。 x  为文档中的表序号, y  是以下的某个参数 :

①        numrows -- int --  表的行数

例如: $rows = $xl_reader->sheets[0]['numrows']

②        numcols -- int --  表的列数

例如: $cols = $xl_reader->sheets[0]['numcols']

③        cells -- array --  表的实际内容。是一个 [row][column]   格式的 2   维数组

    例如: $cell_2_4 = $xl_reader->sheets[0]['cells'][2][4] //   行 2,   列 4   中的数据

④        cellsinfo -- array --  表格中不同数据类型的信息。每个都包含了表格的原始数据和类型。这个数组包含 2   部分: raw --  表格原始数据; type --  数据类型。

注:只显示非文本数据信息。

例如: $cell_info = $xl_reader[0]['cellsinfo'][2][4]

$cell_info['raw'] is the raw data from the cell

$cell_info['type'] is the data type

$xl_reader->sheets

Statement
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function