[英]PHPExcel - Saving weird Characters to Database
我正在使用PHPExcel 1.8.0,2014-03-02。
在Excel中,我具有以下單元格:Ahumada n°301 /Huérfanos
但是在數據庫中顯示:Ahumada n°301 /Huérfanos
有人知道如何解決這個問題嗎?
這是我的代碼:
include 'PHPExcel/IOFactory.php';
$inputFileName = 'data.xlsx';
try {
$objPHPExcel = PHPExcel_IOFactory::load($inputFileName);
}
catch(Exception $e) {
die('Error loading file "'.pathinfo($inputFileName,PATHINFO_BASENAME).'": '.$e->getMessage());
}
$allDataInSheet = $objPHPExcel->getActiveSheet()->toArray(null,true,true,true);
$arrayCount = count($allDataInSheet);
for($i=2;$i<=$arrayCount;$i++){
$local = trim($allDataInSheet[$i]['A']);
$descripcion= trim($allDataInSheet[$i]['B']);
$comuna = trim($allDataInSheet[$i]['C']);
$region = trim($allDataInSheet[$i]['D']);
$insertTable= "INSERT INTO sucursales (Numero, Direccion, Comuna, Region, ID_Cliente) VALUES('".$local."', '".$descripcion."','".$comuna."', '".$region."', '".$_POST['select_cliente2']."');";
mysqli_query($con,$insertTable);
}
謝謝!
我加了
mysqli_set_charset($con, "utf8")
在與mysql的連接中,現在應該可以正常工作了!
謝謝。
我找到了路! 我只是在php中添加了這一行,一切正常!
header('Content-Type: text/html; charset=utf-8');
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.