如何让PHP读取EXCEL文件。

nbabn 2004-06-09 08:12:50
如何让PHP能读取EXCEL文件内的内容?
...全文
6663 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
chinaworker 2004-06-10
  • 打赏
  • 举报
回复
http://chinaz.com/download/s/9459.asp
ccterran 2004-06-10
  • 打赏
  • 举报
回复
http://cn.php.net/manual/en/class.com.php
--------------------------------------------------------
I have searched for ways to open and read an excel document and I found some information which I thought that I would document. Information on the object model to help with programming COM objects can be found in your MS Office help files, search for VBA*.chm.
Also, here is a script that I used to pull a cell from each worksheet, complete w/ variable for pathnames & worksheets. This script also closes excel completely. The coding might be dirty, but it gets the job done.
--------copy from here-----------
<pre>
<?PHP
$filename = "c:/spreadhseet/test.xls";
$sheet1 = 1;
$sheet2 = "sheet2";
$excel_app = new COM("Excel.application") or Die ("Did not connect");
print "Application name: {$excel_app->Application->value}\n" ;
print "Loaded version: {$excel_app->Application->version}\n";
$Workbook = $excel_app->Workbooks->Open("$filename") or Die("Did not open $filename $Workbook");
$Worksheet = $Workbook->Worksheets($sheet1);
$Worksheet->activate;
$excel_cell = $Worksheet->Range("C4");
$excel_cell->activate;
$excel_result = $excel_cell->value;
print "$excel_result\n";
$Worksheet = $Workbook->Worksheets($sheet2);
$Worksheet->activate;
$excel_cell = $Worksheet->Range("C4");
$excel_cell->activate;
$excel_result = $excel_cell->value;
print "$excel_result\n";
#To close all instances of excel:
$Workbook->Close;
unset($Worksheet);
unset($Workbook);
$excel_app->Workbooks->Close();
$excel_app->Quit();
unset($excel_app);
?>
</pre>
nbabn 2004-06-10
  • 打赏
  • 举报
回复
http://chinaz.com/download/s/9459.asp这个真的可以实现读取,就是太复杂了,还有没有更简单点的?
hahawen 2004-06-09
  • 打赏
  • 举报
回复
baidu.com 搜索 “php解析excel” 就可以找到
多菜鸟 2004-06-09
  • 打赏
  • 举报
回复
http://www.phpx.com/happy/showthread.php?s=&threadid=50744&highlight=excel
找到一个不错的类

21,890

社区成员

发帖
与我相关
我的任务
社区描述
从PHP安装配置,PHP入门,PHP基础到PHP应用
社区管理员
  • 基础编程社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧