1 Replies - 211 Views - Last Post: 18 January 2013 - 12:57 PM

#1 wama_mms  Icon User is offline

  • D.I.C Head

Reputation: -1
  • View blog
  • Posts: 54
  • Joined: 06-May 12

problem when exporting arabic data from mysql to excel using php

Posted 18 January 2013 - 12:45 PM

i am using the following code
<?php
	mysql_connect('localhost','root','admin');
	mysql_select_db('body');
	mysql_query("set character_set_server='utf8'");
	mysql_query("set names 'utf8'");
    $result=mysql_query("select * from vendor_group");
    function xlsBOF()
    {
    echo pack("ssssss", 0x809, 0x8, 0x0, 0x10, 0x0, 0x0);
    return;
    }
    function xlsEOF()
    {
    echo pack("ss", 0x0A, 0x00);
    return;
    }
    function xlsWriteNumber($Row, $Col, $Value)
    {
    echo pack("sssss", 0x203, 14, $Row, $Col, 0x0);
    echo pack("d", $Value);
    return;
    }
    function xlsWriteLabel($Row, $Col, $Value )
    {
    $L = strlen($Value);
    echo pack("ssssss", 0x204, 8 + $L, $Row, $Col, 0x0, $L);
    echo $Value;
    return;
    }
	header('Content-type: text/plain; charset=UTF-8'); 
    header("Pragma: public");
    header("Expires: 0");
    header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
    header("Content-Type: application/octet-stream");
    header("Content-Type: application/download");
    header("Content-Disposition: attachment;filename=list.xls");
    header("Content-Transfer-Encoding: binary ");
	
    xlsBOF();
     
    xlsWriteLabel(0,0,"id");
	xlsWriteLabel(0,1,"code");
    xlsWriteLabel(0,2,"name");
    xlsWriteLabel(0,3,"type");
    $xlsRow = 1;
    while($row=mysql_fetch_array($result))
    {
    xlsWriteNumber($xlsRow,0,$row['id']);
    xlsWriteLabel($xlsRow,1,$row['code']);
    xlsWriteLabel($xlsRow,2,$row['name']);
	xlsWriteLabel($xlsRow,3,$row['type']);

    $xlsRow++;
    }
    xlsEOF();
    ?>

to export data from database to excel but the problem is when i export arabic stored data in my database the output in excel sheet doesn't appear

Is This A Good Question/Topic? 0
  • +

Replies To: problem when exporting arabic data from mysql to excel using php

#2 macosxnerd101  Icon User is offline

  • Self-Trained Economist
  • member icon




Reputation: 10767
  • View blog
  • Posts: 40,088
  • Joined: 27-December 08

Re: problem when exporting arabic data from mysql to excel using php

Posted 18 January 2013 - 12:57 PM

You already have an open thread on this topic. Please avoid duplicate posting.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1