<?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";
}
}
}
?>
php生成文档类
最新推荐文章于 2024-08-17 22:56:29 发布