exportar matriz con contenido árabe a archivo de Excel php
Frecuentes
Visto 1,654 equipos
1
i tried to export file from php array contain Arabic characters to Excel file.
it works fine but the content of the Excel file not correct for example:
the value of Array[0]='محمود'
in the Excel file it display ط§ظ„ظƒظ„ظ‰ and it's not related to any Unicode, so here is my code:
$fileName='DaleelAnalytics_'.date("d-m-Y_H:i:s").'.xls';
$fallbackfilename = mb_convert_encoding($fileName, "ISO-8859-1");
$encodedfallbackfilename = rawurlencode($fallbackfilename);
$encodedfilename = rawurlencode($fileName);
header("Content-Disposition: attachment; filename=". $encodedfallbackfilename ."; filename*=windows-1256 $encodedfilename");
$header = array("المعرف", "الإسم", "التخصص", "رقم إذن العمل ", "حالة الحساب", "الهاتف الثابت", "الهاتف المتنقل", "عدد المشاهدات", "تاريخ الاضافة", "التخصص", "الدولة", "المدينة");
$fp = fopen("php://output", "w");
fputcsv($fp, $header, "\t");
foreach ($unsetElementsArray as $row) {
fputcsv($fp, $row, "\t");
}
fclose($fp);die;
i'm sure i have a problem in the encabezamiento
Gracias por su atención.
Perhaps if you tried writing to an actual Excel (BIFF or OfficeOpenXML format) file, rathe rthan to a CSV file, then you wouldn't be subjected to the vagaries of csv-handling across different applications and platforms - Mark Baker
AFAIK Excel chupa at dealing with UTF-8 csv. - Passerby
Most CSV readers suck at dealing with UTF-8 csv - Mark Baker