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

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

israeli 20-06-09 23:21

עזרה - קבל ניתונים לקובץ אקסל
 
ב"ה

שבוע טוב חברים!

אשמח לקבל עזרה איך אני עושה טופס באתר כמו עצומה כזו
שכל הניתונים יגיעו לתוך קובץ הקסאל?

האם זה קיים?

נשמח לקבל קצת פרטים או לינקים תודה רבה!

intercooler3819 20-06-09 23:30

כן למה לא..

אתה צריך מערכת ליצירת קובץ אקסל ומערכת לשליפה ממנו

חכה שניה יעש לי פה משהו שהכנתי למישהו לפני כמה ימים שמייצא טבלאות במסד נתונים לאקסל:
export_mysql_table_to_xls.php:
PHP קוד:

<?php
// SETTINGS

$filename "nitsan_" rand(09999) . ".xls";
$fields = array('CHARACTER_SET_NAME''DEFAULT_COLLATE_NAME''DESCRIPTION');
$tablename 'CHARACTER_SETS';
$db = array('host' => 'localhost',
            
'user' => '',
            
'pass' => '',
            
'name' => 'information_schema');


// END OF SETTINGS! DO NOT EDIT BELOW THIS LINE!

mysql_connect($db['host'], $db['user'], $db['pass']) or die(mysql_error());
mysql_select_db($db['name']) or die(mysql_error());
//mysql_query("SET NAMES 'utf8'") or die(mysql_error());
register_shutdown_function('mysql_close');

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");;
header("Content-Disposition: attachment;filename=".$filename);
header("Content-Transfer-Encoding: binary");

xlsBOF();

for(
$i=0$i sizeof($fields); $i++)
    
xlsWriteLabel(0,$i,$fields[$i]);


$query "SELECT `".implode("`,`"$fields)."` FROM `".$tablename."`";
$query mysql_query($query);

$j 1;
while (
$a mysql_fetch_assoc($query))
{
    for(
$i=0$i sizeof($fields); $i++)
        if (
preg_match("/^([0-9]+|\.[0-9]+|[0-9]+\.[0-9]+)$/"$a[$fields[$i]]))
            
xlsWriteNumber($j$i$a[$fields[$i]]);
        else
            
xlsWriteLabel($j$i$a[$fields[$i]]);
    
    
$j++;
}

xlsEOF();
exit;

// eof

ויש לך את המחלקה הזו שקוראת קבצי XLS:
PHP קוד:

// אין לי פה מקום להביא את כל המחלקה, תחפש בגוגל:
/**
* A class for reading Microsoft Excel Spreadsheets.
*
* Originally developed by Vadim Tkachenko under the name PHPExcelReader.
* (http://sourceforge.net/projects/phpexcelreader)
* Based on the Java version by Andy Khan (http://www.andykhan.com).  Now
* maintained by David Sanders.  Reads only Biff 7 and Biff 8 formats.
*
* PHP versions 4 and 5
*
* LICENSE: This source file is subject to version 3.0 of the PHP license
* that is available through the world-wide-web at the following URI:
* http://www.php.net/license/3_0.txt.  If you did not receive a copy of
* the PHP License and are unable to obtain it through the web, please
* send a note to license@php.net so we can mail you a copy immediately.
*
* @category   Spreadsheet
* @package    Spreadsheet_Excel_Reader
* @author     Vadim Tkachenko <vt@apachephp.com>
* @license    http://www.php.net/license/3_0.txt  PHP License 3.0
* @version    CVS: $Id: reader.php 19 2007-03-13 12:42:41Z shangxiao $
* @link       http://pear.php.net/package/Spreadsheet_Excel_Reader
* @see        OLE, Spreadsheet_Excel_Writer
*/ 


השימוש איתה:
PHP קוד:

<?php
require_once 'class.Spreadsheet_Excel_Reader.php';
$data = new Spreadsheet_Excel_Reader();
$data->setOutputEncoding('CP1255');

echo 
$data->sheets[0]['cells'][0][0];

כאשר ה0 הראשון מייצג את מספר הSHEET, בדרך כלל יש רק אחד, הCELLS מסמל שבא לך לשלוף תאים, ה0 שאחריו מסמל את מספר הטור ואז ה0 הבא את מספר השורה
מספרי הטורים והשורות הם טבעיים גדולים ממינוס אחד

בהצלחה!

israeli 20-06-09 23:49

ב"ה
תודה על התגובה!

הקוד יעזור לי רק לשלוף ממנו ניתונים אבל איך אני רוצה הלכניס לו ניתונים ללא בישתמש במסד או משהוא אחר

יש מצב?


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

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