我想创建一个 XLS 文件,其中包含数据库中的一些信息,我想从数据库中检索的数据都是希腊字符。我有这个代码,当我执行代码时,我只有一些符号。任何人都知道我有什么更改以正确获取希腊字符?编辑:问题在于我从 Mysql 数据库中检索的数据和标题这是代码
$sql = "SELECT tmima,sex,surname,address,postcode,phone1,phone2 FROM student"; //the query
$result = $db->prepare($sql);
$result->execute();
$column = $result->columnCount();
$header = "";
$head = array("Τμήμα","Φ","Επίθετο","Όνομα","Μητρώο"); //headings of the XLS
for($i = 0; $i < $column;$i++ ){
$header .= $head[$i]."\t";
}
$data = "";
while($row = $result->fetch(PDO::FETCH_ASSOC)/*mysql_fetch_row($rec)*/){
$line = '';
foreach($row as $value){
if((!isset($value)) || ($value == " ")){
$value = "\t";
}else{
$value = str_replace( '"' , '""' , $value );
$value = '"' . $value . '"' . "\t";
}//end of if-else
$line .= $value;
}//end of foreach
$data .= trim( $line ) . "\n";
}//end of while($row = mysql_fetch_row($rec))
$data = str_replace("\r" , "" , $data);
if ($data == ""){
$data = "\n No Record Found!\n";
}
header('Content-Description: File Transfer');
header('Content-Type: application/ms-excel; charset=utf8');
header("Content-Disposition: attachment; filename=Student_data.xls");
//header("Content-Transfer-Encoding: binary ");
header("Expires: 0");
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header("Pragma: public");
print "$header\n$data";