PHP Classes

This class is the biz - i've been banging my head against a w...

Recommend this page to a friend!

      Excel Writer  >  All threads  >  This class is the biz - i've been...  >  (Un) Subscribe thread alerts  
Subject:This class is the biz - i've been...
Summary:Package rating comment
Messages:2
Author:Hugo Scott
Date:2008-12-08 15:07:48
Update:2008-12-08 15:13:04
 

Hugo Scott rated this package as follows:

Utility: Good
Consistency: Good
Examples: Good

  1. This class is the biz - i've been...   Reply   Report abuse  
Picture of Hugo Scott Hugo Scott - 2008-12-08 15:07:48
This class is the biz - i've been banging my head against a wall for the past week and a half trying to output French & Chinese UTF-8 msysql results to an xls file and this is the class that cracked it !!

Thanks Harish

PS I will post my implementation on the package forum to show how to change the charset to UTF and auto-download it

  2. Re: This class is the biz - i've been...   Reply   Report abuse  
Picture of Hugo Scott Hugo Scott - 2008-12-08 15:13:04 - In reply to message 1 from Hugo Scott
to change the encoding to UTF-8 you need to change line 106 of excelwriter.inc.php to

<meta http-equiv=Content-Type content="text/html; charset=utf-8">

AND

to make the file auto-download I used


$excel=new ExcelWriter("export.xls");

if($excel==false){
echo $excel->error;
}

$myArr=array("Nom","Prénom","Date naissance","Email","Titre","Adresse","C. P.","Ville","Tél","Pays","Langue","date inscr.","Comment","Fichiers");

$excel->writeLine($myArr);

$excel->close();

//echo "data is write into myXls.xls Successfully."; // you cant' have this or the following headers won't work

$export_file = "export.xls";
header ("Content-type: application/octet-stream;");
header("Expires: 0");
header ("Last-Modified: " . gmdate("D,d M YH:i:s") . " GMT");
header ("Cache-Control: no-cache, must-revalidate");
header ("Pragma: no-cache");
header ("Content-Disposition: attachment; filename=\"".$export_file."\"" );
readfile($export_file);
exit;