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>

解决方案 »

  1.   

    ?  只是一些文章,看能否有点帮助用php生成excel文件
    http://www.chinabs.net/php/default.asp?infoid=331/////////////////////////////////////////////////来自http://heihu.myrice.com/jiaocheng/jiaocheng/php/gjjqindex.htm如果你喜欢冒险,并且在Windows上运行CGI、ISAPI或Apache模块版本的PHP,就可以访问COM的函数。好了,详细解释COM的工作就交给微软和许多大部头的书了,为了能简单地了解一下COM的功能,下面是一小段常见的脚本。  这一段PHP脚本在后端启动微软的字处理Word,打开一个新的文档,输入一些文字,保存文档,并关闭Word。  <?  // 建立一个指向新COM组件的索引  $word = new COM("word.application") or die("Can't start Word!");  // 显示目前正在使用的Word的版本号  echo "Loading Word, v. {$word->Version}<br/>";  // 把它的可见性设置为0(假),如果要使它在最前端打开,使用1(真)  // to open the application in the forefront, use 1 (true)  $word->Visible = 0;  // 在Word中创建新的文档  $word->Documents->Add();  // 在新文档中添加文字  $word->Selection->TypeText("Testing 1-2-3...");  //把文档保存在Windows临时目录中  $word->Documents[1]->SaveAs("/Windows/temp/comtest.doc");  // 关闭与COM组件之间的连接  $word->Quit();  // 在屏幕上显示其他信息  echo "Check for the file...";  ?>  如果你有一个intranet网站,数据存储在SQL Server中,用户需要这些数据的Excel格式,则可以让PHP运行必要的SQL查询并对输出进行格式化,然后利用COM打开Excel,把数据转化为Excel格式的数据,然后把数据保存在用户的台式机上。asp方法:http://bbs1.acnow.net/html/Article/120/3885.htm
      

  2.   

    标记一下.
    我也只做过由mysql导出成xls 的文件.
    从来没有进行过逆向操作
    其实也不知道该怎么实现.今天算是学到了点东西了..
      

  3.   

    excel文件导出成xls文件格式,用mysqladmin导入
      

  4.   

    http://blog.csdn.net/wapweb/archive/2004/09/04/94410.aspx
    (原创)关于如何处理EXCEL( CSV)文件 导入数据库的解决方法!! 
      

  5.   

    可以先把excel导入到ACCESS,然后用php访问access,读取需要的数据insert进mysql.