View Single Post
ישן 24-03-09, 00:05   # 4
intercooler3819
חבר וותיק
 
מיני פרופיל
תאריך הצטרפות: Jul 2008
הודעות: 1,056

intercooler3819 לא מחובר  

http://.co.il/dev/xls_creation/

הקוד..
PHP קוד:
<?php
$content 
"";

if (isset(
$_POST['cn49c']))
{
    function 
xlsBOF()
    {
        echo 
pack("ssssss"0x8090x80x00x100x0,0x0);
    }

    function 
xlsEOF()
    {
        echo 
pack("ss"0x0A0x00);
    }

    function 
xlsWriteNumber($Row$Col$Value)
    {
        echo 
pack("sssss"0x20314$Row$Col0x0);
        echo 
pack("d"$Value);
    }

    function 
xlsWriteLabel($Row$Col$Value)
    {
        
$L strlen($Value);
        echo 
pack("ssssss"0x204$L$Row$Col0x0$L);
        echo 
$Value;
    }

    
header("Pragma:public");
    
header("Expires:0");
    
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
    
header("Content-Type:application/force-download");
    
header("Content-Type:application/octet-stream");
    
header("Content-Type:application/download");;
    
    if (
preg_match("/^[0-9a-zA-Z]+$/"$_POST['x95nc']))
        
header("Content-Disposition: attachment;filename=" $_POST['x95nc'] . ".xls ");
    
elsez
        header
("Content-Disposition: attachment;filename=nitsan_" rand(09999) . ".xls ");
    
    
header("Content-Transfer-Encoding: binary");

    
xlsBOF();

    
xlsWriteLabel(0,0,"List of values:");

    
$content explode("\n"$_POST['cn49c']);
    for (
$i 0$i count($content); $i++)
    {
        
$content[$i] = explode(","$content[$i]);
        for (
$j 0$j count($content[$i]); $j++)
            if (
preg_match("/^([0-9]+|\.[0-9]+|[0-9]+\.[0-9]+)$/"$content[$i][$j]))
                
xlsWriteNumber($i$j$content[$i][$j]);
            else
                
xlsWriteLabel($i$j$content[$i][$j]);
    }

    
xlsEOF();
    exit;
}
else
{
$content .= <<<EOF
Each new line is new row and ',' is the cols separator<br />
<form action="index.php" method="post">
Filename:&nbsp;<input type='text' value='' name='x95nc' />.xls<br />
<textarea name="cn49c" cols="60" rows="8"></textarea>
<div class='button'><input type="submit" value="xls it!" /></div>
</form>
EOF;
}
__________________
  Reply With Quote