![]() |
| ||
| encoding problem with csv/excel Dear Sir, I have a PHP script that export CSV with arabic text, for example I download the CSV on the website then save to desktop of my computer and Open it on NOTEPAD... that works fine I could still see all the arabic text OK with no problem, but if I open the CSV file in Microsoft EXCEL, all the arabic text are busted and no longer readable. Do you know a solution for this, how could I make it work OK on MS Excel, because the user want it to view the CSV file in Excel. Regards, Fauk Chowdhury. [CODE] mysql_connect("localhost", "root", "root123"); mysql_select_db("medgulf"); // mention the file name to display in download prompt $file_name = "download.txt"; header("Content-Disposition: attachment; filename=\"$file_name\""); header("Cache-Control: cache, must-revalidate"); header("Pragma: public"); header('Content-Type: text/xml, charset=UTF-8; encoding=UTF-8'); $fd1 = $_POST['fd']; $fm1 = $_POST['fm']; $fy1 = $_POST['fy']; // Output header //echo "Name,Code"."\n"; $frmday = $fy1."-".$fm1."-".$fd1; $ld1 = $_POST['ld']; $lm1 = $_POST['lm']; $ly1 = $_POST['ly']; $today = $ly1."-".$lm1."-".$ld1; //echo $frmday; $usrname = $_POST['usname']; $export_date = date("Y-m-d"); $result = mysql_query("SELECT product,agent_code,policy_no,DATE_FORMAT(entry_date,'%d/%m/%Y'),DATE_FORMAT(inception_date_eng,'%d/%m/%Y'),DATE_FORMAT(expiry_date_eng,'%d/%m/%Y'),DATE_FORMAT(inception_date_hijri,'%d/%m/%Y'),DATE_FORMAT(expiry_date_hijri,'%d/%m/%Y'),client_info.first_name,client_info.family_name,client_info.father_name,client_info.grand_father_name,client_info.mobile_no,client_info.dob,client_info.p_o_box,client_info.zip_code,client_info.city,client_info.id_type,client_info.id_no,license_type,net_premium,brandname,model,reg_type,plate_no,model_year,chassis_no,color,age_limit,user_name FROM vehicle_info,client_info where vehicle_info.policy_no = client_info.sr AND entry_date BETWEEN '$frmday' AND '$today' AND user_name='$usrname' AND exported='no' "); if($result) { while($rs = mysql_fetch_array($result)) { echo $rs[0].","; echo $rs[1].","; echo $rs[2].","; echo $rs[3].","; echo $rs[4].","; echo $rs[5].","; echo $rs[6].","; echo $rs[7].","; echo $rs[8].","; echo $rs[9].","; echo $rs["family_name"].","; echo $rs["grand_father_name"].","; echo $rs["mobile_no"].","; echo $rs["dob"].","; echo $rs["p_o_box"].","; echo $rs["zip_code"].","; echo $rs["city"].","; echo $rs["id_type"].","; echo $rs["id_no"].","; echo $rs["license_type"].","; echo $rs["net_premium"].","; echo $rs["brandname"].","; echo $rs["model"].","; echo $rs["reg_type"].","; echo $rs["plate_no"].","; echo $rs["model_year"].","; echo $rs["chassis_no"].","; echo $rs["color"].","; echo " ".","; echo " ".","; echo $rs["age_limit"].","; echo $rs["user_name"]."\n"; } } else { echo "There Is No Data To Export "; } |
| ||
| Re: encoding problem with csv/excel Did ur Excel installed with arabic text compatibility? |
| ||
| Re: encoding problem with csv/excel Quote:
|
| ||
| Re: encoding problem with csv/excel you could change the encoding of the page from utf-8 to windows-1256 i guess that would work better |
| ||
| Re: encoding problem with csv/excel Quote:
i added the character set and encoding with windows-1256. but it keeps same problem as before.simply if i send an arabic character i.e echo "س"; then it does not comes at excel shet.so can you tel me l how to send data from php file to excel with utf8 or windows-1256 format. i.e encoding method of sending data. please reply . this is so much urgent for me. Regards, Faruk chowdhury [code] <?php header('Content-Type: text/xml, charset=windows-1256; enucoding=windows-1256'); ?> |
| All times are GMT -4. The time now is 9:05 pm. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC