4

我已经安装了 PEARSpreadsheet_Excel_Writer和 OLE。示例程序已成功执行,但是当我尝试读取文件时,它显示垃圾值。我也试过$workbook->setVersion(8);$worksheet->setInputEncoding('UTF-8');

我正在使用本教程和谷歌来解决这个问题。
http://www.sitepoint.com/article/getting-started-with-pear/3/

提前致谢。

4

2 回答 2

2

I try to use PEAR only when I really need to...you can easily generate an excel spreadsheet( assuming it's just data) with something like this:

$header = "Last Name\tFirst Name\tAge\tJob\n"; // new line is start of new row, tab is next column

//ideally you would get this from a DB and just loop through it and append on
$row1 = "Smith\tBob\t25\tManager\n";
$row2 = "Anderson\tTrent\t32\tCEO\n";

$excel = $header.$row1.$row2;

$xlsfile = "excel_example".date("m-d-Y-hiA").".xls";
header('Content-type: application/vnd.ms-excel');
header("Content-Disposition: attachment; filename=$xlsfile");
echo $excel;
于 2008-12-23T16:54:25.980 回答
0

不过,这只是一个制表符分隔值文件,您发送的标题建议浏览器将该数据视为 excel 文件。所以没有海报可能需要的数据格式。

于 2009-09-16T22:36:59.827 回答