Exporting to excel, column types to be text

Good day

I have the following code which exports mysql data to excel and it works:

$fileName = “per_manager_report_”.date(‘Ymd’)."_".$username . “.xls”;
header(“Content-Type: application/xls”);
header(“Content-Disposition: attachment; filename=”$fileName"");
echo $output;

Please help with two issues,

  1. When opening the downloaded file it asks for language, how do I hard code this so that it’s automatically.

  2. If the field has numbers, example 0823123, its not saved as text so the “0” infront is gone, >> 823123. How to auto text.

Kind Regards

Well, that depends on how you created the $output file in xls format. Which library did you use?
Normally to set numbers with leading zeros, you need to set all your numeric columns to format that way.
The library you used should have a column-format option to set the formatting. Not sure if this helps you,
but, perhaps you can give more info on your code. You only showed the rendering of it, not how you created it…

Sponsor our Newsletter | Privacy Policy | Terms of Service