和Spreadsheet_Excel_Writer类似,Spreadsheet_Excel_Reader是用来读取Excel内容的工具。 可以方便的将Excel数据导入到数据或者其他用途。 如下代码: ? php //调用Reader require_once ' Spreadsheet/Excel/Reader/reader.php '; //创建 Reader $data = new
和Spreadsheet_Excel_Writer类似,Spreadsheet_Excel_Reader是用来读取Excel内容的工具。
可以方便的将Excel数据导入到数据或者其他用途。
如下代码:
<span></span>php <span>//调用Reader</span> <span>require_once</span> '<span>Spreadsheet/Excel/Reader/reader.php</span>'; <span>//创建 Reader</span> $data = new Spreadsheet_Excel_Reader(); <span>//设置文本输出编码</span> $data->setOutputEncoding('<span>GB2312</span>'); <span>//读取Excel文件</span> $data-><span>read</span>("<span>c:\test.xls</span>"); <span>//$data->sheets[0]['numRows']为Excel行数</span> <span>for</span> ($i = 1; $i sheets[0]['<span>numRows</span>']; $i++) { <span> //$data->sheets[0]['numCols']为Excel列数</span> <span> for</span> ($j = 1; $j sheets[0]['<span>numCols</span>']; $j++) { <span> //显示每个单元格内容</span> <span> echo</span> $data->sheets[0]['<span>cells</span>'][$i][$j]; } } <span>?></span>
另,由于日期型的特殊性,在取值时可能会产生错误,可将Excel单元格类型设为Text,
将日期以文本形式读取,如需日期型字符再通过PHP对其进行处理即可(strtotime()结合date())。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

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

Hot Article

Hot Tools

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

SublimeText3 Chinese version
Chinese version, very easy to use

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

WebStorm Mac version
Useful JavaScript development tools

Atom editor mac version download
The most popular open source editor
