PHP:使用PEAR写入excel文件 [英] PHP:Writing to excel file using PEAR
问题描述
我已经安装了PEAR,Spreadsheet_Excel_Writer
和OLE.该示例程序已成功执行,但是当我尝试读取该文件时,它显示了垃圾值.我还尝试了$workbook->setVersion(8);
和$worksheet->setInputEncoding('UTF-8');
I have installed PEAR, Spreadsheet_Excel_Writer
and OLE. The sample program is executed successfully but when I try to read the file it shows garbage values. I also tried $workbook->setVersion(8);
and $worksheet->setInputEncoding('UTF-8');
我正在使用本教程和Google很多用于解决此问题.
http://www.sitepoint.com/article/getting-started -with-pear/3/
I am using this tutorial and Google lot for this problem.
http://www.sitepoint.com/article/getting-started-with-pear/3/
谢谢.
推荐答案
我仅在确实需要时才尝试使用PEAR ...您可以轻松地生成具有以下内容的excel电子表格(假定它只是数据):
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;
这篇关于PHP:使用PEAR写入excel文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!