Ver Mensaje Individual
  #8 (permalink)  
Antiguo 21/06/2011, 10:36
Avatar de fernandaYO
fernandaYO
 
Fecha de Ingreso: mayo-2011
Ubicación: Medellin
Mensajes: 166
Antigüedad: 12 años, 11 meses
Puntos: 4
Respuesta: php Excel reader

vale!

Código PHP:
<?php

$con
mysql_connect ('localhost''user''pass') or die ('Error en la base de datos');
$bddmysql_select_db ('aplicaciones') or die ('Error en la bdd'.mysl_error());

 
?>
<?php

define
('NUM_BIG_BLOCK_DEPOT_BLOCKS_POS'0x2c);
define('SMALL_BLOCK_DEPOT_BLOCK_POS'0x3c);
define('ROOT_START_BLOCK_POS'0x30);
define('BIG_BLOCK_SIZE'0x200);
define('SMALL_BLOCK_SIZE'0x40);
define('EXTENSION_BLOCK_POS'0x44);
define('NUM_EXTENSION_BLOCK_POS'0x48);
define('PROPERTY_STORAGE_BLOCK_SIZE'0x80);
define('BIG_BLOCK_DEPOT_BLOCKS_POS'0x4c);
define('SMALL_BLOCK_THRESHOLD'0x1000);
define('SIZE_OF_NAME_POS'0x40);
define('TYPE_POS'0x42);
define('START_BLOCK_POS'0x74);
define('SIZE_POS'0x78);
define('IDENTIFIER_OLE'pack("CCCCCCCC",0xd0,0xcf,0x11,0xe0,0xa1,0xb1,0x1a,0xe1));

function 
GetInt4d($data$pos) {
    
$value ord($data[$pos]) | (ord($data[$pos+1])    << 8) | (ord($data[$pos+2]) << 16) | (ord($data[$pos+3]) << 24);
    if (
$value>=4294967294) {
        
$value=-2;
    }
    return 
$value;
}

// http://uk.php.net/manual/en/function.getdate.php
function gmgetdate($ts null){
    
$k = array('seconds','minutes','hours','mday','wday','mon','year','yday','weekday','month',0);
    return(
array_comb($k,split(":",gmdate('s:i:G:j:w:n:Y:z:l:F:U',is_null($ts)?time():$ts))));
    } 

function 
array_comb($array1$array2) {
    
$out = array();
    foreach (
$array1 as $key => $value) {
        
$out[$value] = $array2[$key];
    }
    return 
$out;
}

function 
v($data,$pos) {
    return 
ord($data[$pos]) | ord($data[$pos+1])<<8;
}
class 
OLERead {
    var 
$data '';
    function 
OLERead(){    }

    function 
read($sFileName){
        
        if(!
is_readable($sFileName)) {
            
$this->error 1;
            return 
false;
        }
        
$this->data = @file_get_contents($sFileName);
        if (!
$this->data) {
            
$this->error 1;
            return 
false;
           }
           if (
substr($this->data08) != IDENTIFIER_OLE) {
            
$this->error 1;
            return 
false;
           }
        
$this->numBigBlockDepotBlocks GetInt4d($this->dataNUM_BIG_BLOCK_DEPOT_BLOCKS_POS);
        
$this->sbdStartBlock GetInt4d($this->dataSMALL_BLOCK_DEPOT_BLOCK_POS);
        
$this->rootStartBlock GetInt4d($this->dataROOT_START_BLOCK_POS);
        
$this->extensionBlock GetInt4d($this->dataEXTENSION_BLOCK_POS);
        
$this->numExtensionBlocks GetInt4d($this->dataNUM_EXTENSION_BLOCK_POS);
        
$bigBlockDepotBlocks = array();
        
$pos BIG_BLOCK_DEPOT_BLOCKS_POS;
        
$bbdBlocks $this->numBigBlockDepotBlocks;
        if (
$this->numExtensionBlocks != 0) {
            
$bbdBlocks = (BIG_BLOCK_SIZE BIG_BLOCK_DEPOT_BLOCKS_POS)/4;
        }
        
$Referencia $data[0];
        
$Talla $data[1];
        
$Base $data[2];
        
$Escote $data[3];
        
$Sisa $data[4];
        
$Altura $data[5];
        
$Tirante $data[6];
        
$sql="INSERT INTO prueba2 (Referencia, Talla, Base, Escote, Sisa, Altura, Tirante, Imagen) VALUES ('$Referencia', '$Talla', '$Base', '$Escote', '$Sisa', '$Altura', '$Tirante', 'NULL')";

        for (
$i 0$i $bbdBlocks$i++) {
            
$bigBlockDepotBlocks[$i] = GetInt4d($this->data$pos);
            
$pos += 4;
        }
        for (
$j 0$j $this->numExtensionBlocks$j++) {
            
$pos = ($this->extensionBlock 1) * BIG_BLOCK_SIZE;
            
$blocksToRead min($this->numBigBlockDepotBlocks $bbdBlocksBIG_BLOCK_SIZE 1);

            for (
$i $bbdBlocks$i $bbdBlocks $blocksToRead$i++) {
                
$bigBlockDepotBlocks[$i] = GetInt4d($this->data$pos);
                
$pos += 4;
            }
            
$bbdBlocks += $blocksToRead;
            if (
$bbdBlocks $this->numBigBlockDepotBlocks) {
                
$this->extensionBlock GetInt4d($this->data$pos);
            }
        }
        
$pos 0;
        ...............................

?>
eso es todo je

Toco recortarlo mucho por que no cabia!
__________________
Umm, infraccion :(//