Foros del Web » Programando para Internet » PHP »

php y excel

Estas en el tema de php y excel en el foro de PHP en Foros del Web. hola, estoy tratando de generar un archivo excel en php el cual pueda manipular, agregar modifica, borrar datos. trate de usar phpexcel pero no me ...
  #1 (permalink)  
Antiguo 16/02/2014, 13:27
 
Fecha de Ingreso: julio-2013
Mensajes: 123
Antigüedad: 10 años, 9 meses
Puntos: 1
php y excel

hola, estoy tratando de generar un archivo excel en php el cual pueda manipular, agregar modifica, borrar datos. trate de usar phpexcel pero no me funciono, si alguien sabe de alguna idea se lo agradezco.
  #2 (permalink)  
Antiguo 16/02/2014, 18:43
Avatar de Patriarka  
Fecha de Ingreso: enero-2011
Ubicación: Moreno, Buenos Aires, Argentina
Mensajes: 2.851
Antigüedad: 13 años, 2 meses
Puntos: 288
Respuesta: php y excel

phpexcel es lo que debrias usar, tiene una pilada de documentacion.
sino crea un .csv y listo
  #3 (permalink)  
Antiguo 16/02/2014, 20:54
 
Fecha de Ingreso: julio-2013
Mensajes: 123
Antigüedad: 10 años, 9 meses
Puntos: 1
Respuesta: php y excel

ya lo descargue pero cuando lo voy a usar me manda infinidad de errorres.
  #4 (permalink)  
Antiguo 17/02/2014, 08:29
 
Fecha de Ingreso: julio-2013
Mensajes: 123
Antigüedad: 10 años, 9 meses
Puntos: 1
Respuesta: php y excel

los errores que me evia son estos..

Código &lt:
Ver original
  1. Warning: require_once(PHPExcel.php): failed to open stream: No such file or directory in C:\wamp\www\excelllllllll\phpexcel_ejemplo\index.php on line 6

Código &lt:
Ver original
  1. Fatal error: require_once(): Failed opening required 'PHPExcel.php' (include_path='.;C:\php\pear;./Classes/') in C:\wamp\www\excelllllllll\phpexcel_ejemplo\index.php on line 6

el codigo. index.php

Código PHP:
Ver original
  1. <?php
  2. /** Incluir la ruta **/
  3. set_include_path(get_include_path() . PATH_SEPARATOR . './Classes/');
  4.  
  5. /** Clases necesarias */
  6. require_once('PHPExcel.php');
  7. require_once('PHPExcel/Reader/Excel2007.php');
  8.  
  9. // Variables de la página
  10. $_VIEWDATA = array(
  11.     'v_precioTotal' => 0,
  12.     'v_descuento' => 0,
  13.     'v_precioFinal' => 0
  14. );
  15.  
  16. // Petición de cálculo?
  17. if (isset($_REQUEST['boton_calcular'])) {
  18.     // Cargando la hoja de cálculo
  19.     $objReader = new PHPExcel_Reader_Excel2007();
  20.     $objPHPExcel = $objReader->load("calculo.xlsx");
  21.    
  22.     // Asignar hoja de calculo activa
  23.     $objPHPExcel->setActiveSheetIndex(0);
  24.    
  25.     // Asignar data
  26.     $objPHPExcel->getActiveSheet()->setCellValue('automatico', $_REQUEST['transmision_Automatica']);
  27.     $objPHPExcel->getActiveSheet()->setCellValue('cuero', $_REQUEST['asientos_Cuero']);
  28.     $objPHPExcel->getActiveSheet()->setCellValue('suspension', $_REQUEST['suspension']);
  29.    
  30.     // Calculos
  31.     $_VIEWDATA['v_precioTotal'] = $objPHPExcel->getActiveSheet()->getCell('total')->getCalculatedValue();
  32.     $_VIEWDATA['v_descuento'] = $objPHPExcel->getActiveSheet()->getCell('descuento')->getCalculatedValue();
  33.     $_VIEWDATA['v_precioFinal'] = $objPHPExcel->getActiveSheet()->getCell('final')->getCalculatedValue();
  34. }
  35. ?>
  36. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  37. <html xmlns="http://www.w3.org/1999/xhtml">
  38. <head>
  39. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  40. <title>Ejemplo</title>
  41. </head>
  42.  
  43. <body>
  44.     <form id="formulario" method="post" name="formulario" action="index.php">
  45.         <table>
  46.             <tr>
  47.                 <th>Transmisi&oacute;n autom&aacute;tica :</th>
  48.                 <td>
  49.                     <select id="transmision_Automatica" name="transmision_Automatica">
  50.                         <?php if(isset($_REQUEST['transmision_Automatica'])) { ?>
  51.                         <option value="<?php echo $_REQUEST['transmision_Automatica']; ?>" selected="selected"><?php echo $_REQUEST['transmision_Automatica']; ?></option>
  52.                         <?php } ?>
  53.                         <option value="No">No</option>
  54.                         <option value="Si">Si</option>
  55.                     </select>
  56.                 </td>
  57.             </tr>
  58.             <tr>
  59.                 <th>Asientos de cuero:</th>
  60.                 <td>
  61.                     <select id="asientos_Cuero" name="asientos_Cuero">
  62.                         <?php if(isset($_REQUEST['asientos_Cuero'])) { ?>
  63.                         <option value="<?php echo $_REQUEST['asientos_Cuero']; ?>" selected="selected"><?php echo $_REQUEST['asientos_Cuero']; ?></option>
  64.                         <?php } ?>
  65.                         <option value="No">No</option>
  66.                         <option value="Si">Si</option>
  67.                     </select>
  68.                 </td>
  69.             </tr>
  70.             <tr>
  71.                 <th>Suspensi&oacute;n:</th>
  72.                 <td>
  73.                     <select id="suspension" name="suspension">
  74.                         <?php if(isset($_REQUEST['suspension'])) { ?>
  75.                         <option value="<?php echo $_REQUEST['suspension']; ?>" selected="selected"><?php echo $_REQUEST['suspension']; ?></option>
  76.                         <?php } ?>
  77.                         <option value="No">No</option>
  78.                         <option value="Si">Si</option>
  79.                     </select>
  80.                 </td>
  81.             </tr>
  82.             <tr>
  83.                 <th>&nbsp;</th>
  84.                 <td>
  85.                     <input id="boton_calcular" name="boton_calcular" type="submit" value="Calcular" />
  86.                 </td>
  87.             </tr>
  88.         </table>
  89.     </form>
  90.     <?php if (isset($_REQUEST['boton_calcular'])) { ?>
  91.    
  92.     <h2>Detalles del Precio</h2>
  93.     <p>Basado en tus preferencias, el precio de tu carro será S/. <?php echo number_format($_VIEWDATA['v_precioFinal'], 2); ?> Nuevos Soles.</p>
  94.     <table>
  95.         <tr>
  96.             <th>Precio Total:</th>
  97.             <td><?php echo number_format($_VIEWDATA['v_precioTotal'], 2); ?> Nuevos Soles</td>
  98.         </tr>
  99.         <tr>
  100.             <th>Descuento:</th>
  101.             <td><?php echo number_format($_VIEWDATA['v_descuento'] * 100, 2); ?>%</td>
  102.         </tr>
  103.         <tr>
  104.             <td colspan="2"><hr noshade="noshade"></hr>
  105.         </tr>
  106.         <tr>
  107.             <th>Total Final:</th>
  108.             <td><?php echo number_format($_VIEWDATA['v_precioFinal'], 2); ?> Nuevos Soles</td>
  109.         </tr>
  110.     </table>
  111.     <p><a href="index.php">Calcular nuevo precio</a></p>
  112.    
  113.     <?php } ?>
  114. </body>
  115. </html>

phpexcel-basic.php

Código PHP:
Ver original
  1. <?php
  2.  
  3. require_once '../Classes/PHPExcel.php';
  4.  
  5. $objPHPExcel = new PHPExcel();
  6.  
  7.  
  8. $objPHPExcel->
  9.     getProperties()
  10.         ->setCreator("TEDnologia.com")
  11.         ->setLastModifiedBy("TEDnologia.com")
  12.         ->setTitle("Exportar Excel con PHP")
  13.         ->setSubject("Documento de prueba")
  14.         ->setDescription("Documento generado con PHPExcel")
  15.         ->setKeywords("usuarios phpexcel")
  16.         ->setCategory("reportes");
  17.  
  18.  
  19. $objPHPExcel->setActiveSheetIndex(0)
  20.             ->setCellValue('A1', 'Nombre')
  21.             ->setCellValue('B1', 'E-mail')
  22.             ->setCellValue('C1', 'Twitter')
  23.             ->setCellValue('A2', 'David')
  24.             ->setCellValue('B2', '[email protected]')
  25.             ->setCellValue('C2', '@davidvd');
  26.  
  27.  
  28.  
  29. $objPHPExcel->getActiveSheet()->setTitle('Usuarios');
  30. $objPHPExcel->setActiveSheetIndex(0);
  31.  
  32.  
  33. header('Content-Type: application/vnd.ms-excel');
  34. header('Content-Disposition: attachment;filename="01simple.xls"');
  35. header('Cache-Control: max-age=0');
  36.  
  37. $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
  38. $objWriter->save('php://output');

espero me puedas ayudar.

Etiquetas: excel
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 16:28.