tags:

views:

644

answers:

2

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');

I am using this tutorial and Google lot for this problem.
http://www.sitepoint.com/article/getting-started-with-pear/3/

Thanks in advance.

+2  A: 

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;
Jack
this is a .csv vile, not a real .xls binary file.
cweiske
A: 

that's just a tab seperated value file though and you're sending headers suggesting the browser treat that data as an excel file. so there's no formatting of data which the poster may require.

kguest