Ver Mensaje Individual
  #1 (permalink)  
Antiguo 14/03/2011, 06:16
asrael
 
Fecha de Ingreso: marzo-2010
Mensajes: 102
Antigüedad: 14 años, 1 mes
Puntos: 2
ayuda con phpExcelReader

Buenas estoy usando esta libreria para leer un .xls e introducir cada fila en una tabla de mi BD pero me pasa un problema y es que cuando introduzco algun registro con acentos me sale raro cuando lo muestro despues de introducirlo en la tabla.

¿Saben como puedo solucionarlo?

Aqui dejo algo del codigo:

Código PHP:
Ver original
  1. require_once 'phpExcelReader/Excel/reader.php';
  2.  
  3.  
  4. // ExcelFile($filename, $encoding);
  5. $data = new Spreadsheet_Excel_Reader();
  6.  
  7.  
  8. // Set output Encoding.
  9. $data->setOutputEncoding('CP1251');
  10.  
  11.  
  12.  
  13. $data->read('xls/prueba.xls');
  14.  
  15.  
  16.  
  17. error_reporting(E_ALL ^ E_NOTICE);
  18. $empresa;
  19. $direccion;
  20. $cp;
  21. $poblacion;
  22. $provincia;
  23. $web;
  24. $telefono;
  25. $sector;
  26. $nivel;
  27. $cliente;
  28. $c;
  29.  
  30.  
  31. for ($i = 1; $i <= $data->sheets[0]['numRows']; $i++) {
  32.     for ($j = 1; $j <= $data->sheets[0]['numCols']; $j++) {
  33.        
  34.         if($j == 1){
  35.         $empresa=$data->sheets[0]['cells'][$i][$j];
  36.         }else{
  37.        
  38.         }
  39.        
  40.         if($j == 2){
  41.         $direccion=$data->sheets[0]['cells'][$i][$j];
  42.         }else{
  43.        
  44.         }
  45.         if($j == 3){
  46.         $cp=$data->sheets[0]['cells'][$i][$j];
  47.         }else{
  48.        
  49.         }
  50.         if($j == 4){
  51.         $poblacion=$data->sheets[0]['cells'][$i][$j];
  52.         }else{
  53.        
  54.         }
  55.         if($j == 5){
  56.         $provincia=$data->sheets[0]['cells'][$i][$j];
  57.         }else{
  58.        
  59.         }
  60.         if($j == 6){
  61.         $web=$data->sheets[0]['cells'][$i][$j];
  62.         }else{
  63.        
  64.         }
  65.        
  66.         if($j == 7){
  67.         $telefono=$data->sheets[0]['cells'][$i][$j];
  68.         }else{
  69.        
  70.         }
  71.         if($j == 8){
  72.         $sector=$data->sheets[0]['cells'][$i][$j];
  73.         }else{
  74.        
  75.         }
  76.         if($j == 9){
  77.         $nivel=$data->sheets[0]['cells'][$i][$j];
  78.         }else{
  79.        
  80.         }
  81.         if($j == 10){
  82.         $cliente=$data->sheets[0]['cells'][$i][$j];
  83.         }else{
  84.        
  85.         }
  86.        
  87.         if($j == $data->sheets[0]['numCols'] ){
  88.         require('seguridad.php');
  89.         conectar_base_datos();
  90.  
  91.         mysql_query("INSERT INTO clientes (empresa,direccion,poblacion,telefono,provincia) VALUES   ('$empresa','$direccion','$poblacion','$telefono','$provincia')");
  92.        
  93.     }
  94. }

Por ejemplo en el nombre de la empresa visto desde el phpmyadmin me sale que pone "impresión" pero cuando lo muestro me sale "impresi�n"

Un saludo y gracias por la ayuda