您的位置:首页 > 编程语言 > PHP开发

php生成文档类

2007-07-27 16:17 190 查看
<?php
/**
 *  educe class for word&excel&txt
 *  this class is used in all scripts
 *  do NOT fiddle unless you know what you are doing
 *
 *  Copyright(c) 2007 by qiqi. All rights reserved
 *
 *  To contact the author write to {@link qqi_77@sina.com}
 *
 * @author qqi77
 *
 */
class Educe
{
 /**
  * description : document educe
  *
  * @param string $fileName
  * @param array $titleName
  * @param array $dataName
  * @param string $fileMark 0:excel 1:txt 2:word
  */
 function documentEduce($fileMark,$fileName,$titleName,$dataName)
 {
  header("Content-Type: application/vnd.ms-excel");
  switch ($fileMark)
  {
   case 0:
   echo header("Content-Disposition: attachment; filename=$fileName.xls");
   break;
   case 1:
   echo header("Content-Disposition: attachment; filename=$fileName.txt");
   break;
   case 2:
   echo header("Content-Disposition: attachment; filename=$fileName.doc");
   break;
  }
  header("Pragma: no-cache");
  header("Expires: 0");
  $num=count($titleName);
  for ($i=0;$i<$num;$i++)
  {
   echo "".$titleName[$i].""."/t";
  }
  if ($i==$num)
  {
   echo "".$titleName[$i].""."/t/n";
  }
  for ($y=0;$y<$num;$y++)
  {
   echo "".$dataName[$y].""."/t";
  }
  if ($y==$num)
  {
   echo "".$dataName[$y].""."/t/n";
  }
 }
}
?>

 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息