Foros del Web » Programando para Internet » PHP »

[Ayuda] Como usar funciones & este code

Estas en el tema de [Ayuda] Como usar funciones & este code en el foro de PHP en Foros del Web. 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 ...
  #1 (permalink)  
Antiguo 02/05/2010, 08:24
 
Fecha de Ingreso: septiembre-2009
Mensajes: 230
Antigüedad: 14 años, 6 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;
                }
        }
?>

Etiquetas: code, funciones
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 21:59.