הוסטס - פורום אחסון האתרים הגדול בישראל

הוסטס - פורום אחסון האתרים הגדול בישראל (https://hosts.co.il/forums/index.php)
-   פורום תיכנות (https://hosts.co.il/forums/forumdisplay.php?f=14)
-   -   יצוא תוכן של דף לאקסל (excel) (https://hosts.co.il/forums/showthread.php?t=72894)

spi7fire 23-03-09 13:52

יצוא תוכן של דף לאקסל (excel)
 
היי חבר'ה,
אני רוצה לייצא טבלה שאני מציג ללקוח (מדפיס אותה עם php) לקובץ ecxel ולפתוח את הקובץ לאחר היצירה (ע"י לחיצה על כפתור)

מישהו מכיר קוד שעושה את זה?

תודה

Adir 23-03-09 14:59

http://www.google.co.il/search?hl=iw...+excel&spell=1

spi7fire 23-03-09 22:15

גם אני יודע לחפש בגוגל. לא סתם שאלתי כאן בפורום אם מישהו מכיר קוד שעושה את זה, כי אם היית פחות מתעצל ובאמת מסתכל על התוצאות היית רואה שאין שם משהו באמת ברור שאפשר להשתמש בו.

intercooler3819 24-03-09 00:05

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;
}


spi7fire 24-03-09 20:20

וואי ניצן, תודה רבה! אתה מלך! :)

זה עובד כמו סוס..

0xfo7d 24-03-09 23:42

היי ניצן,
ניסיתי גם את הקוד...הוא נותן שגיאה:
Parse error: syntax error, unexpected T_STRING in /home/***/domains/***/public_html/***.php on line 39


כל הזמנים הם GMT +2. הזמן כעת הוא 03:12.

מופעל באמצעות VBulletin גרסה 3.8.6
כל הזכויות שמורות ©
כל הזכויות שמורות לסולל יבוא ורשתות (1997) בע"מ