0

I'm using PHPExcel version 1.8.0, 2014-03-02.

In the Excel I have this kind of cells: Ahumada nº 301 / Huérfanos

But in the database shows: Ahumada nº 301 / Huérfanos

Any one knows how to fix this?

This is my code:

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);
}

Thanks!

Thomas Fifield
  • 137
  • 2
  • 3
  • 9
  • PHPExcel works with UTF-8 data.... make sure your database connection is UTF-8, and that your tables are set for UTF-8 - http://stackoverflow.com/questions/279170/utf-8-all-the-way-through – Mark Baker Oct 04 '15 at 21:27

2 Answers2

1

I added

mysqli_set_charset($con, "utf8")

In the connection to mysql and now is working as it should be!

Thanks.

Thomas Fifield
  • 137
  • 2
  • 3
  • 9
0

I found the way! I just add this line in the php and everything worked!

header('Content-Type: text/html; charset=utf-8');
Thomas Fifield
  • 137
  • 2
  • 3
  • 9