请问谁有导出excel的实例代码,千万别答复说去下载PHPExcel啊,我还是新手,不懂配置那东西啊,最好谁有页面和类代码实例,把代码贴上来吧,谢谢

解决方案 »

  1.   


    $export_file = "test.xls";
    ob_end_clean();
    ini_set('zlib.output_compression','Off');header('Pragma: public');
    header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");                   
    header('Last-Modified: '.gmdate('D, d M Y H:i:s') . ' GMT');
    header('Cache-Control: no-store, no-cache, must-revalidate');     // HTTP/1.1
    header('Cache-Control: pre-check=0, post-check=0, max-age=0');    // HTTP/1.1
    header ("Pragma: no-cache");
    header("Expires: 0");
    header('Content-Transfer-Encoding: none');
    header('Content-Type: application/vnd.ms-excel;');                 // This should work for IE & Opera
    header("Content-type: application/x-msexcel");                    // This should work for the rest
    header('Content-Disposition: attachment; filename="'.basename($export_file).'"'); echo "test1" . "\t";
    echo "test2" . "\t";
    echo "test3" . "\n";
      

  2.   


    <?php 
    header("<meta http-equiv=\"content-type\" content=\"text/html;charset=uft-8\">");
    header("Content-Type: application/vnd.ms-excel");
    header("content-disposition: attachment;filename=test.xls");
    $arr = array(
        '0'=>array('name'=>'zhangshan','age'=>'22'),
        '1'=>array('name'=>'zhangshan','age'=>'22'),
        '2'=>array('name'=>'zhangshan','age'=>'22'),
        '3'=>array('name'=>'zhangshan','age'=>'22'),
    );
    echo "name" . "\t";
    echo "age" . "\t";
    echo "\n";
    foreach($arr as $value) {
        
        echo $value['name'] . "\t";
        echo $value['age'] . "\t";
        echo "\n";
    }
    ?> 
      

  3.   

    如果一个页面显示10行,5列的数据,是从数据库读取出来的,点击生成excel按钮,就生成10行,5列的excel表格,楼上2位兄弟的方法好像对这种数据量大点的就不行了吧,很麻烦
      

  4.   

    我有一个php导出excel的文件,你写php调用就可以,如果要的话我就把实例给你
      

  5.   

    可以到处为CVS格式或者用html的<table>形式然后加上上面所说的header就可以了header('Content-Type: application/vnd.ms-excel;');                 // This should work for IE & Opera
    header("Content-type: application/x-msexcel");                    // This should work for the rest
    header('Content-Disposition: attachment; filename="'.basename($export_file).'"'); 
      

  6.   

    Goooooooooooooooooooooooooooooooooooooooooooooooooood
      

  7.   

    我刚做完这个~费了好大的劲哦~奉献啦~
    <?
          header("Content-type:application/vnd.ms-excel");
          header("Content-Disposition:filename=信息.xls");
          require('../include/config.inc');
          $link_id=mysql_connect($dbhost,$dbuser,$dbpassword);
          mysql_select_db($dbname,$link_id);
      set_time_limit(0);
         $province=$_POST['province'];
       $city=$_POST['city'];
       $area=$_POST['area'];
      echo "id\t";
      echo "classname\t";
      echo "area\t";
      echo "userbh\t";
      echo "userkh\t";
      echo "addtime\t";
      echo "isjrfs\t";
      echo "issrfs\t";
      echo "zhiwu\t";
      echo "danwei\t";
      echo "beizhu\t";
      echo "username\t";
      echo "password\t";
      echo "pname\t";
      echo "psex\t";
      echo "dtime\t";
      echo "address\t";
      echo "province\t";
      echo "city\t";
      echo "area\t";
      echo "code\t";
      echo "tel\t";
      echo "phone\t";
      echo "bbname\t";
      echo "bbsex\t";
      echo "bbdtime\t";
      echo "bbparent\t";
      echo "email\t";
      echo "point\t\n";
      $str="select * from member where area='$area'";
      $result=mysql_query($str,$link_id);
      while($rs=mysql_fetch_array($result)){
      echo $rs['id']."\t";
              echo $rs['classname']."\t";
      echo $rs['area']."\t";
          echo $rs['userbh']."\t";
          echo $rs['userkh']."\t";
          echo $rs['addtime']."\t";
              echo $rs['isjrfs']."\t";
              echo $rs['issrfs']."\t";
          echo $rs['zhiwu']."\t";
      echo $rs['danwei']."\t";
              echo $rs['beizhu']."\t";
          echo $rs['username']."\t";
          echo $rs['password']."\t";
          echo $rs['pname']."\t";
              echo $rs['psex']."\t";
              echo $rs['dtime']."\t";
          echo $rs['address']."\t";
      echo $rs['province']."\t";
              echo $rs['city']."\t";
          echo $rs['area']."\t";
          echo $rs['code']."\t";
          echo $rs['tel']."\t";
              echo $rs['phone']."\t";
              echo $rs['bbname']."\t";
          echo $rs['bbsex']."\t";
      echo $rs['bbdtime']."\t";
              echo $rs['bbparent']."\t";
          echo $rs['email']."\t";
          echo $rs['point']."\t\n";
                }
    mysql_close($link_id);
    ?> 记得上一页要把变量传递过来哦~
      

  8.   

    能否导出成Office2007的格式呢?