我正在使用PHPExcel版本1.8.0,2014-03-02。PHPExcel - 将奇怪的字符保存到数据库中
在Excel工作我有这样的细胞: 阿乌马达Nº301 /Huérfanos
但在数据库显示: 阿乌马达nº301 /华©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);
}
谢谢!
PHPExcel可与UTF-8的数据....请确保您的数据库连接是UTF-8,你的表是UTF-8的设置 - http://stackoverflow.com/questions/279170/utf-8 -all-the-way-through –