Foros del Web » Programando para Internet » PHP »

Generar Excel con Spreadsheet Excel Writer

Estas en el tema de Generar Excel con Spreadsheet Excel Writer en el foro de PHP en Foros del Web. Hola gente de ForosdelWeb, veran no os vengo a preguntar como hacer esto (Porque ya he entendido la manera como trabaja esta clase), mi pregunta ...
  #1 (permalink)  
Antiguo 18/07/2012, 08:26
Avatar de anacona16  
Fecha de Ingreso: marzo-2010
Ubicación: Bogota DC
Mensajes: 610
Antigüedad: 14 años, 1 mes
Puntos: 52
Generar Excel con Spreadsheet Excel Writer

Hola gente de ForosdelWeb, veran no os vengo a preguntar como hacer esto (Porque ya he entendido la manera como trabaja esta clase), mi pregunta es? porque funciona en un Microsoft Excel 2011 de MAC OSX y no en un Microsoft Excel 2010 de Windows, cuando estaba en el trabajo estuve creando el archivo .php que generaria el excel y funciono perfectamente, pero llegue a mi casa (alla tengo un PC con windows ) y cuando genere el archivo me di cuenta que buff no funcionaba, y pues como podrar asemejar el 99.9% de los usuarios que usarian este generardor de excel pues usan, PC con Windows...

El codigo que tengo para generar mi excel es el siguiente:

Código PHP:
<?php

require_once 'clases/Writer.php';

$workbook  = new Spreadsheet_Excel_Writer();

$worksheet =& $workbook->addWorksheet();
$worksheet->setLandscape();

// Merge cells from row 0, col 0 to row 2, col 2
$formatHeader       =& $workbook->addFormat(array('Align' => 'center''Bold' => true'Size' => 12));
$formatDatosColegio =& $workbook->addFormat(array('Align' => 'center''Bold' => true'Size' => 10));
$formatTitle        =& $workbook->addFormat(array('Align' => 'center''Size' => 12));
$formatNota         =& $workbook->addFormat(array('Align' => 'center''Border' => 1'NumFormat' => '0.0'));
$formatNotaFinal    =& $workbook->addFormat(array('Align' => 'center''Border' => 1'NumFormat' => '0.0''FgColor' => 55'Bold' => true));
$formatNotaFinal->setLocked();
$formatAutoIncremet =& $workbook->addFormat(array('Border' => 1));
$formatDocumento    =& $workbook->addFormat(array('Border' => 1'Align' => 'right'));
$formatEstudiante   =& $workbook->addFormat(array('Border' => 1));

/*Ancho de las columnas*/

$worksheet->setColumn(003);
$worksheet->setColumn(1120);
$worksheet->setColumn(2240);
$worksheet->setColumn(3175);

$worksheet->writeString(00$_SESSION['infocol1'], $formatHeader);
$worksheet->mergeCells(00025);

$worksheet->writeString(10$_SESSION['infocol2'], $formatHeader);
$worksheet->mergeCells(10125);

$worksheet->writeString(20$_SESSION['nombcole'] . " - SEDE " $_SESSION['nombsede'], $formatHeader);
$worksheet->mergeCells(20225);

$worksheet->writeString(30$_SESSION['resocole'], $formatDatosColegio);
$worksheet->mergeCells(30325);

$worksheet->writeString(40"DANE " $_SESSION['danecole'] . " NIT " $_SESSION['nnitcole'], $formatDatosColegio);
$worksheet->mergeCells(40425);


$worksheet->writeString(60"PLANILLA DE SEGUIMIENTO ACADEMICO Y CONVIVENCIA PARA DILIGENCIAR OFFLINE"$formatTitle);
$worksheet->mergeCells(60625);

foreach(
$datos as $dato):    

    
$indiceFila 14;
    
$i          1;
    
    foreach(
$dato['estudiantes'] as $estudiante):
    
        
$worksheet->write($indiceFila0$i$formatAutoIncremet);
        
$worksheet->write($indiceFila1$estudiante['idenestu'], $formatDocumento);
        
$worksheet->write($indiceFila2$estudiante['Estudiante'], $formatEstudiante);
        
$worksheet->write($indiceFila3$estudiante['not1val1'], $formatNota);
        
$worksheet->write($indiceFila4$estudiante['not2val1'], $formatNota);
        
$worksheet->write($indiceFila5$estudiante['not3val1'], $formatNota);
        
$worksheet->write($indiceFila6$estudiante['not4val1'], $formatNota);
        
$worksheet->write($indiceFila7$estudiante['not5val1'], $formatNota);
        
$worksheet->write($indiceFila8$estudiante['not6val1'], $formatNota);
        
$worksheet->write($indiceFila9$estudiante['not7val1'], $formatNota);
        
$worksheet->write($indiceFila10$estudiante['not8val1'], $formatNota);
        
$worksheet->write($indiceFila11$estudiante['not9val1'], $formatNota);
        
$worksheet->write($indiceFila12$estudiante['not0val1'], $formatNota);
        
        
$worksheet->writeFormula($indiceFila13"=AVERAGE(D" $indiceFila ":M" $indiceFila ")"$formatNotaFinal);
        
        
$worksheet->writeNumber($indiceFila14$estudiante['not1val2'], $formatNota);
        
$worksheet->writeNumber($indiceFila15$estudiante['not2val2'], $formatNota);
        
$worksheet->writeNumber($indiceFila16$estudiante['not3val2'], $formatNota);
        
        
$worksheet->writeFormula($indiceFila17"=AVERAGE(O" $indiceFila ":Q" $indiceFila ")"$formatNotaFinal);
        
        
$worksheet->writeNumber($indiceFila18$estudiante['not1val3'], $formatNota);
        
$worksheet->writeNumber($indiceFila19$estudiante['not2val3'], $formatNota);
        
        
$worksheet->writeFormula($indiceFila20"=AVERAGE(S" $indiceFila ":T" $indiceFila ")"$formatNotaFinal);
        
        
$i++;
        
$indiceFila++;
        
    endforeach;
    
endforeach;

$workbook->send('planilla_calificaion_completa.xls');
$workbook->close();
El error que me da al abrir el archivo en Office 2010 de Windows es: "El archivo esta dañada intente abrir y reparar (o algo asi)"

Al ver que esto no me funciono busque otra clase la PHPExcel pero para hacer lo mismo que hago con Spreadsheet Excel Writer pues son muchas mas lineas de codigo...
__________________
Aprendiendo!!!

Etiquetas: excel, spreadsheet, writer, usuarios
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 07:15.