当前位置: 网学 > 编程文档 > PHP > 正文

php编程实现获取excel文档内容的代码实例

来源:Http://myeducs.cn 联系QQ:点击这里给我发消息 作者: 用户投稿 来源: 网络 发布时间: 13/06/22

鉴于大家对PHP十分关注,我们编辑小组在此为大家搜集整理了“php编程实现获取excel文档内容的代码实例”一文,供大家参考学习

1、readexcel.system.php
复制代码 代码如下:
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* A class for reading Microsoft Excel Spreadsheets.
*
* Originally developed by Vadim Tkachenko under the name PHPExcelReader.
* (http://sourceforge.net/projects/phpexcelreader)
* Based on the Java version by Andy Khan (http://www.3ppt.com). Now
* maintained by David Sanders. Reads only Biff 7 and Biff 8 formats.
*
* PHP versions 4 and 5
*
* LICENSE: This source file is subject to version 3.0 of the PHP license
* that is available through the world-wide-web at the following URI:
* http://www.php.net/license/3_0.txt. If you did not receive a copy of
* the PHP License and are unable to obtain it through the web, please
* send a note to license@php.net so we can mail you a copy immediately.
*
* @category Spreadsheet
* @package Spreadsheet_Excel_Reader
* @author Vadim Tkachenko <vt@apachephp.com>
* @license http://www.php.net/license/3_0.txt PHP License 3.0
* @version CVS: $Id: reader.php 19 2007-03-13 12:42:41Z shangxiao $
* @link http://pear.php.net/package/Spreadsheet_Excel_Reader
* @see OLE, Spreadsheet_Excel_Writer
*/
//require_once ''PEAR.php'';
//require_once ''oleread.php'';
//oleread.php的内容start=======================================================================================================
define(''NUM_BIG_BLOCK_DEPOT_BLOCKS_POS'', 0x2c);
define(''SMALL_BLOCK_DEPOT_BLOCK_POS'', 0x3c);
define(''ROOT_START_BLOCK_POS'', 0x30);
define(''BIG_BLOCK_SIZE'', 0x200);
define(''SMALL_BLOCK_SIZE'', 0x40);
define(''EXTENSION_BLOCK_POS'', 0x44);
define(''NUM_EXTENSION_BLOCK_POS'', 0x48);
define(''PROPERTY_STORAGE_BLOCK_SIZE'', 0x80);
define(''BIG_BLOCK_DEPOT_BLOCKS_POS'', 0x4c);
define(''SMALL_BLOCK_THRESHOLD'', 0x1000);
// property storage offsets
define(''SIZE_OF_NAME_POS'', 0x40);
define(''TYPE_POS'', 0x42);
define(''START_BLOCK_POS'', 0x74);
define(''SIZE_POS'', 0x78);
define(''IDENTIFIER_OLE'', pack("CCCCCCCC",0xd0,0xcf,0x11,0xe0,0xa1,0xb1,0x1a,0xe1));
//echo ''ROOT_START_BLOCK_POS = ''.ROOT_START_BLOCK_POS."n";
//echo bin2hex($data[ROOT_START_BLOCK_POS])."n";
//echo "a=";
//echo $data[ROOT_START_BLOCK_POS];
//function log
function GetInt4d($data, $pos)
{
$value = ord($data[$pos]) | (ord($data[$pos+1]) << 8) | (ord($data[$pos+2]) << 16) | (ord($data[$pos+3]) << 24);
if ($value>=4294967294)
{
$value=-2;
}
return $value;
}
class OLERead {
var $data = '''';
function OLERead(){
}
function read($sFileName){
// check if file exist and is readable (Darko Miljanovic)
if(!is_readable($sFileName)) {
$this->error = 1;
return false;
}
$this->data = @file_get_contents($sFileName);
if (!$this->data) {
$this->error = 1;
return false;
}
//echo IDENTIFIER_OLE;
//echo ''start'';
if (substr($this->data, 0, 8) != IDENTIFIER_OLE) {
$this->error = 1;
return false;
}
$this->numBigBlockDepotBlocks = GetInt4d($this->data, NUM_BIG_BLOCK_DEPOT_BLOCKS_POS);
$this->sbdStartBlock = GetInt4d($this->
  • 上一篇资讯: PHP学习笔记之数组篇
  • 网学推荐

    免费论文

    原创论文

    浏览:
    设为首页 | 加入收藏 | 论文首页 | 论文专题 | 设计下载 | 网学软件 | 论文模板 | 论文资源 | 程序设计 | 关于网学 | 站内搜索 | 网学留言 | 友情链接 | 资料中心
    版权所有 QQ:3710167 邮箱:3710167@qq.com 网学网 [Myeducs.cn] 您电脑的分辨率是 像素
    Copyright 2008-2015 myeducs.Cn www.myeducs.Cn All Rights Reserved
    湘ICP备09003080号