Advertisement

09.17.2007 at 03:40AM PDT, ID: 22832774
[x]
Attachment Details

Arabic text not displayed in excel when exported from mysql using php

Asked by paraman_dxb in PHP Scripting Language, PHP and Databases, MySQL

Tags: arabic, mysql, text

Hi,

I want to download data from mysql  to excel using Php. below is my code. it is working fine. But when it comes to arabic text, i am not getting arabic text displayed in excel. it is showing junk characters. In the database i  am storing the data in unicode. If i download the data in text format i can see them in arabic but not in excel. How can i solve this issue and get the data downloaded to excel with arabic text.

Thanks in advance

Paraman.




<?php include("dbConnect.php"); ?>
<?php
            $rowcount = 0;
            $data1  = "select * from forum07";
            $result = mysql_query($data1) or die('Error, query failed');
            $rowcount=mysql_num_rows($result);
            $fieldcount = mysql_num_fields($result);

$header = "<table> <tr>";

            for ($i = 0; $i < $fieldcount; $i++)
            {
            $header = $header. "<td>".mysql_field_name($result, $i)."</td>";
            }

$header = $header."</tr>";

                  while($row = mysql_fetch_row($result))
                  {
                  $line = "<tr>";
                        foreach($row as $value)
                        {
                                    if ((!isset($value)) OR ($value == ""))
                                    {
                                    $value = "<td></td>";
                                    }
                                    else
                                    {
                                    //$value = str_replace('"', '""', $value);
                                    $value = '<td>'.$value ."</td>";
                                    }
                              $line .= $value;
                        }
                  $data .= trim($line)."</tr>";
                  }
            // $data = str_replace("\r","", $data);
            
            if ($data =="")
            {
            $data = "n(0) Records Found!n";
            }

header("Content-type:application/vnd.ms-excel; charset=windows-1256");
//header("Content-type: application/octet-stream");
header("Content-Disposition: attachment; filename=FORUM07_DATA.xls");
header("Pragma: no-cache");
header("Expires: 0");
print  $header.$data."</table>"

?>Start Free Trial
[+][-]09.17.2007 at 03:48AM PDT, ID: 19903903

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: PHP Scripting Language, PHP and Databases, MySQL
Tags: arabic, mysql, text
Sign Up Now!
Solution Provided By: wasifg
Participating Experts: 2
Solution Grade: B
 
 
[+][-]09.17.2007 at 03:50AM PDT, ID: 19903914

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.17.2007 at 03:53AM PDT, ID: 19903921

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.17.2007 at 04:03AM PDT, ID: 19903964

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.18.2007 at 03:49AM PDT, ID: 19911583

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09.18.2007 at 04:33AM PDT, ID: 19911774

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_1_20070628