Ver Mensaje Individual
  #1 (permalink)  
Antiguo 02/05/2010, 08:24
kirst
 
Fecha de Ingreso: septiembre-2009
Mensajes: 230
Antigüedad: 14 años, 7 meses
Puntos: 2
[Ayuda] Como usar funciones & este code

Buenas tardes, tengo un código para mostrar XLS, quisiera saber como usar la función porque la verdad NO tengo IDEA!! Saludos de ante mano.

prueba.php
Código PHP:
<?php
        
require_once('clsBook.php');
        class 
ReportExcel
        
{
                function 
ReportExcel()
                {
                }
                function 
ShowExcel($data,$title)
                {
                        
$libro = new WorkBook();
                        
$titulos explode(',',$title);
                        
$tabla = &$libro->WorkSheets[0]->Table;
                        
//creamos el tipo de fuente
                        
$fuente = new Font();
                        
$fuente->FontName 'Century Gothic';
                        
$fuente->FontSize 8;
                        
$fuente->Bold 1;
                        
//el tipo de estilo asocido a ese fuente
                        
$estilo = new Style('report');
                        
$estilo->Font $fuente;
                        
//adicionamos
                        
$libro->addStyle($estilo);
                                
$fila = new Row();
                                
$celda = new Cell("REPORTE");
                                
$celda->StyleId 'report';
                                
$fila->addCell($celda);
                                
$tabla->addRow($fila);
                                
$fila = new Row();
                                
$Cl=1;
                                foreach(
$titulos as $value)
                                {
                                    
$col = new Column();
                                    
$col->Width 100;
                                    
$col->Index $Cl;
                                    
$tabla->addColumn($col);
                                    
$celda = new Cell(strtoupper($value));
                                    
$celda->StyleId 'report';
                                    
$fila->addCell($celda);
                                    
$Cl++;
                                }
                            
$tabla->addRow($fila);
                            
                        if (
count($data) > 1){
                        
$c=count($data);
                        
$f=count($data[0]);
                        
$cont=0;
                        while (
$cont $f)
                        {
                                
$fila = new Row();
                                
$cont1 0;
                                    while (
$cont1 $c)
                                    {
                                    
$celda = new Cell($data[$cont1][$cont]);
                                    
$fila->addCell($celda);
                                    
$cont1++;
                                    }
                                    
$tabla->addRow($fila);
                        
$cont++;
                        }
                        }else{
                            foreach(
$data as $Datos)
                            {
                                        foreach(
$Datos as $valu)
                                        {
                                            
$fila = new Row();
                                            
$celda = new Cell($valu);
                                            
$fila->addCell($celda);
                                            
$tabla->addRow($fila);
                                        }
                            }
                        }
                        
$libro->OutPut('attachment''Reporte.xls');
                        return;
                }
        }
?>