Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP export excel unicode ( russian chars ) problem
    primarykey
    data
    text
    <p>I have used below code to export excel file using php. For english text, I didn't find any issues. But Russian characters I find some issues. I have attached my code.</p> <pre><code>mysql_connect("localhost","USERNAME","PASSWORD"); mysql_select_db("DATABASE"); mysql_query("SET NAMES 'UTF8'"); // Get data records from table. $result=mysql_query("select * from usertbl order by user_id asc"); // Functions for export to excel. 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("Pragma: public"); header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Content-type: application/vnd.ms-excel;charset:UTF-8"); header("Content-Type: application/force-download"); header("Content-Type: application/octet-stream"); header("Content-Type: application/download"); header("Content-Disposition: attachment;filename=orderlist.xls "); header("Content-Transfer-Encoding: binary "); xlsBOF(); /* Make a top line on your excel sheet at line 1 (starting at 0). The first number is the row number and the second number is the column, both are start at '0'*/ xlsWriteLabel(0,0,"List of car company."); // Make column labels. (at line 3) xlsWriteLabel(2,0,"No."); xlsWriteLabel(2,1,"Nickname"); $xlsRow = 3; // Put data records from mysql by while loop. while($row=mysql_fetch_array($result)){ xlsWriteNumber($xlsRow,0,$row['user_id']); //$row['nickname']= iconv('UTF-8', 'SJIS', $row['NAME']); //$row['nickname'] = mb_convert_encoding($row['NAME'], 'UTF-16LE', 'UTF-8'); xlsWriteLabel($xlsRow,1,$row['NAME']); $xlsRow++; } xlsEOF(); exit(); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload