לוגו אתר Fresh          
 
 
  אפשרות תפריט  ראשי     אפשרות תפריט  צ'אט     אפשרות תפריט  מבזקים     אפשרות תפריט  צור קשר     חץ שמאלה ‎print ‎"Hello World!"; if‎ ‎not rules.‎know ‎then rules.‎read(); חץ ימינה  

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



  #1  
ישן 30-01-2008, 19:17
צלמית המשתמש של tnadav1
  משתמש זכר tnadav1 tnadav1 אינו מחובר  
 
חבר מתאריך: 02.10.05
הודעות: 2,355
שלח הודעה דרך MSN אל tnadav1
הודעה מעצבנת בייצוא לקובץ אקסל

אני השתמשתי בקוד הזה (אחרי כמה שיפורים) שמצאתי בפורום:
קוד PHP:
<?php
//Written by Dan Zarrella. Some additional tweaks provided by JP Honeywell
//pear excel package has support for fonts and formulas etc.. more complicated
//this is good for quick table dumps (deliverables)

$linkID=mysql_connect('/*DELETED*/''/*DELETED*/''/*DELETED*/');

// Fixing UTF-8 Problem, and conneting to the ssten Database 
mysql_query("SET NAMES utf8");
mysql_select_db('teneView');

$result mysql_query('select * from `pages`'$linkID);
$count mysql_num_fields($result);

for (
$i 0$i $count$i++){
    
$header .= mysql_field_name($result$i)."\t,";
}

while(
$row mysql_fetch_row($result)){
  
$line '';
  foreach(
$row as $value){
    if(!isset(
$value) || $value == ""){
      
$value "\t";
    }else{
# important to escape any quotes to preserve them in the data.
      
$value str_replace('"''""'$value);
# needed to encapsulate data in quotes because some data might be multi line.
# the good news is that numbers remain numbers in Excel even though quoted.
      
$value '"' $value '"' "\t,";
    }
    
$line .= $value;
  }
  
$data .= trim($line)."\n";
}
# this line is needed because returns embedded in the data have "\r"
# and this looks like a "box character" in Excel
  
$data str_replace("\r"""$data);


# Nice to let someone know that the search came up empty.
# Otherwise only the column name headers will be output to Excel.
if ($data == "") {
  
$data "\nno matching records found\n";
}

# This line will stream the file to the user rather than spray it across the screen
header("Content-type: application/octet-stream");

# replace excelfile.xls with whatever you want the filename to default to
header("Content-Disposition: attachment; filename=excelfile.xls");
header("Pragma: no-cache");
header("Expires: 0");

echo 
$header."\n".$data;
?>

והמידע מופיע באקסל בצורה טובה והכל, רק שלפני שזה מציג את הטבלה (באקסל 2007) אני מקבל את ההודעה הבאה:

תמונה שהועלתה על ידי גולש באתר ולכן אין אנו יכולים לדעת מה היא מכילה
יש דרך להיפתר מההודעה הזאת? שתפעל בשרת לינוקס?
_____________________________________


תגובה ללא ציטוט תגובה עם ציטוט חזרה לפורום
  #3  
ישן 31-01-2008, 12:48
צלמית המשתמש של tnadav1
  משתמש זכר tnadav1 tnadav1 אינו מחובר  
 
חבר מתאריך: 02.10.05
הודעות: 2,355
שלח הודעה דרך MSN אל tnadav1
בתגובה להודעה מספר 2 שנכתבה על ידי yoavmatchulsky שמתחילה ב "אני חושב שזה בעיה ב Content..."

תיקנתי קצת את הקוד:
קוד PHP:
<?php
$linkID
=mysql_connect('l--', --', '--');
// Fixing UTF-8 Problem, and conneting to the ssten Database
mysql_query("SET NAMES utf8");
mysql_select_db('
teneView');

// Fixing UTF-8 Problem, and conneting to the ssten Database 
mysql_query("SET NAMES utf8");
mysql_select_db('
teneView');

$result = mysql_query('
select from `pages`', $linkID);
$count = mysql_num_fields($result);

$header = '';
for ($i = 0; $i < $count; $i++){
    $header .= mysql_field_name($result, $i)."\t,";
}

$data = '';
while($row = mysql_fetch_row($result)){
  $line = '';
  foreach($row as $value){
    if(!isset($value) || $value == ""){
      $value = "\t,";
    }else{
# important to escape any quotes to preserve them in the data.
      $value = str_replace('"', '""', 
$value);
# needed to encapsulate data in quotes because some data might be multi line.
# the good news is that numbers remain numbers in Excel even though quoted.
      
$value = '"' . $value . '"' . "\t,";
    }
    
$line .= $value;
  }
  
$data .= trim($line)."\n";
}
# this line is needed because returns embedded in the data have "
\r"
# and this looks like a "
box character" in Excel
  
$data = str_replace("\r", "", $data);


# Nice to let someone know that the search came up empty.
# Otherwise only the column name headers will be output to Excel.
if (
$data == "") {
  
$data = "\nno matching records found\n";
}

# Nice to let someone know that the search came up empty.
# Otherwise only the column name headers will be output to Excel.

# This line will stream the file to the user rather than spray it across the screen
header("
Content-typeapplication/octet-stream");

# replace excelfile.xls with whatever you want the filename to default to
header('Pragma: public');
header("
ExpiresMon26 Jul 1997 05:00:00 GMT");                  // Date in the past   
header('Last-Modified: '.gmdate('D, d M Y H:i:s') . ' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');     // HTTP/1.1
header('Cache-Control: pre-check=0, post-check=0, max-age=0');    // HTTP/1.1
header ("
Pragmano-cache");
header("
Expires0");
header('Content-Transfer-Encoding: none');
header("
Content-typeapplication/vnd.ms-excel");                // This should work for IE & Opera
header("
Content-typeapplication/x-msexcel");                    // This should work for the rest
header('Content-Disposition: attachment; filename="'.basename("excelfile.xls").'"');

echo 
$header."\n".$data;
?>

עדיין אותה בעיה
_____________________________________



נערך לאחרונה ע"י tnadav1 בתאריך 31-01-2008 בשעה 13:11.
תגובה ללא ציטוט תגובה עם ציטוט חזרה לפורום
  #5  
ישן 31-01-2008, 13:11
צלמית המשתמש של tnadav1
  משתמש זכר tnadav1 tnadav1 אינו מחובר  
 
חבר מתאריך: 02.10.05
הודעות: 2,355
שלח הודעה דרך MSN אל tnadav1
בתגובה להודעה מספר 4 שנכתבה על ידי yoavmatchulsky שמתחילה ב "תנסה להוריד את ה..."

לא פותר את הבעיה..
קוד PHP:
<?php
$linkID
=mysql_connect('--''--''--');

// Fixing UTF-8 Problem, and conneting to the ssten Database
mysql_query("SET NAMES utf8");
mysql_select_db('teneView');

// Fixing UTF-8 Problem, and conneting to the ssten Database 
mysql_query("SET NAMES utf8");
mysql_select_db('teneView');

$result mysql_query('select * from `pages`'$linkID);
$count mysql_num_fields($result);

$header '';
for (
$i 0$i $count$i++){
    
$header .= mysql_field_name($result$i)."\t,";
}

$data '';
while(
$row mysql_fetch_row($result)){
  
$line '';
  foreach(
$row as $value){
    if(!isset(
$value) || $value == ""){
      
$value "\t";
    }else{
# important to escape any quotes to preserve them in the data.
      
$value str_replace('"''""'$value);
# needed to encapsulate data in quotes because some data might be multi line.
# the good news is that numbers remain numbers in Excel even though quoted.
      
$value '"' $value '"' "\t,";
    }
    
$line .= $value;
  }
  
$data .= trim($line)."\n";
}
# this line is needed because returns embedded in the data have "\r"
# and this looks like a "box character" in Excel
  
$data str_replace("\r"""$data);


# Nice to let someone know that the search came up empty.
# Otherwise only the column name headers will be output to Excel.
if ($data == "") {
  
$data "\nno matching records found\n";
}

# Nice to let someone know that the search came up empty.
# Otherwise only the column name headers will be output to Excel.

# This line will stream the file to the user rather than spray it across the screen
//header("Content-type: application/octet-stream");

# replace excelfile.xls with whatever you want the filename to default to
header('Pragma: public');
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");                  // Date in the past   
header('Last-Modified: '.gmdate('D, d M Y H:i:s') . ' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');     // HTTP/1.1
header('Cache-Control: pre-check=0, post-check=0, max-age=0');    // HTTP/1.1
header ("Pragma: no-cache");
header("Expires: 0");
header('Content-Transfer-Encoding: none');
header("Content-Type: application/vnd.ms-excel");                // This should work for IE & Opera
header("Content-Type: application/x-msexcel");                    // This should work for the rest
header('Content-Disposition: attachment; filename="'.basename("excelfile.xls").'"');

echo 
$header."\n".$data;
?>

ניסיתי גם להשאיר רק Content-Type אחד וזה לא עזר..

ניסיתי אפילו לכתוב את המידע הבינארי, וזה בכלל ייצא אסון..
הנה המחלקה שכתבתי:
קוד PHP:
<?php
/*-----------------------------------------*\
| TeneView System, 2007 (C)                    |
| Developed by Nadav Tenenbaum                |
| Version 1.0 Beta                            |
| ------------------------------------------|
| File: excel.class.php                        |
| MVC: View                                    |
| Excel writer class                        |
\*-----------------------------------------*/

class ExcelFile {
    var 
$pos;         // Array: Holding row and col position
    
var $fileDATA;     // String: Holding the excel binary data
    
var $started;     // Bool: is the file stated?
    
var $ended;     // Bool: is the file ended?

    
function ExcelFile() {
        
// Set initial position
        
$this->pos      = array('row'=>0'col'=>0);    // Zero-set position
        
$this->fileDATA '';                            // Make file data empty
        
        
$this->started     false;                        // File is not yet started
        
$this->ended    false;                        // file is not yet ended
        
        
$this->BOF();
    }
    
    function 
BOF() {                // Void: Mark the .xls Begin Of File mark
        
if(!$this->started) {
            
$this->fileDATA pack("vvvvvv"0x8090x080x00,0x100x00x0);
            
$this->started     true;
        }
    }
    
    function 
EOF() {                // Void: Mark the .xls End Of File mark
        
if(!$this->ended) {
            
$this->fileDATA .= pack("vv"0x0A0x00);
            
$this->ended     true;
        }
    }
    
    function 
textCell($value) {        // Void: Creates a cell with string value
        
$length strlen($value);
        
$this->fileDATA .= pack("v*"0x0204$length$this->pos['row'], $this->pos['col'], 0x00$length);
        
$this->fileDATA .= $value;
        
        
$this->nextCell();
    }
    
    function 
intCell($value) {        // Void: Creates a cell with integer value
        
$value = (int) $value;
        
$this->fileDATA .= pack("vvvvv"0x020314$this->pos['row'], $this->pos['col'], 0x00);
        
$this->fileDATA .= pack("d"$value);
        
        
$this->nextCell();
    }
    
    function 
nextCell() {            // Void: Set the marker to next cell
        
$this->pos['col']++;
    }
    
    function 
newRow() {                // Void: Set the marker to the first cell in next row
        
$this->pos['col'] = 0;
        
$this->pos['row']++;
    }
    
    function 
setPos($row$col) {    // Void: Changes the class marker position
        
$this->pos['col'] = (int) $col;
        
$this->pos['row'] = (int) $row;
    }

    function 
getBinary() {            // String: return the binary data of the file to any use
        
return $this->fileDATA;
    }
}
?>

מישהו מוכן לנסות אותה על Office 2003? יכול להיות שהבעיה זה השימוש ב- Office 2007?
_____________________________________


תגובה ללא ציטוט תגובה עם ציטוט חזרה לפורום
  #6  
ישן 31-01-2008, 14:52
צלמית המשתמש של tnadav1
  משתמש זכר tnadav1 tnadav1 אינו מחובר  
 
חבר מתאריך: 02.10.05
הודעות: 2,355
שלח הודעה דרך MSN אל tnadav1
בתגובה להודעה מספר 5 שנכתבה על ידי tnadav1 שמתחילה ב "לא פותר את הבעיה.. ..."

הבעיה תוקנה ע"י שינוי הסיומת ל- CSV
קוד PHP:
<?php
$linkID
=mysql_connect('--''--''--');
// Fixing UTF-8 Problem, and conneting to the ssten Database
mysql_query("SET NAMES utf8");
mysql_select_db('teneView');

// Fixing UTF-8 Problem, and conneting to the ssten Database 
mysql_query("SET NAMES utf8");
mysql_select_db('teneView');

$result mysql_query('select * from `pages`'$linkID);
$count mysql_num_fields($result);

$header '';
for (
$i 0$i $count$i++){
    
$header .= mysql_field_name($result$i)."\t,";
}

$data '';
while(
$row mysql_fetch_row($result)){
  
$line '';
  foreach(
$row as $value){
    if(!isset(
$value) || $value == ""){
      
$value "\t";
    }else{
# important to escape any quotes to preserve them in the data.
      
$value str_replace('"''""'$value);
# needed to encapsulate data in quotes because some data might be multi line.
# the good news is that numbers remain numbers in Excel even though quoted.
      
$value '"' $value '"' "\t,";
    }
    
$line .= $value;
  }
  
$data .= trim($line)."\n";
}
# this line is needed because returns embedded in the data have "\r"
# and this looks like a "box character" in Excel
  
$data str_replace("\r"""$data);


# Nice to let someone know that the search came up empty.
# Otherwise only the column name headers will be output to Excel.
if ($data == "") {
  
$data "\nno matching records found\n";
}

# Nice to let someone know that the search came up empty.
# Otherwise only the column name headers will be output to Excel.

# This line will stream the file to the user rather than spray it across the screen
//header("Content-type: application/octet-stream");

# replace excelfile.xls with whatever you want the filename to default to
header('Pragma: public');
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");                  // Date in the past   
header('Last-Modified: '.gmdate('D, d M Y H:i:s') . ' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');     // HTTP/1.1
header('Cache-Control: pre-check=0, post-check=0, max-age=0');    // HTTP/1.1
header ("Pragma: no-cache");
header("Expires: 0");
header('Content-Transfer-Encoding: none');
//header("Content-Type: application/vnd.ms-excel");                // This should work for IE & Opera
header("Content-Type: application/x-csv");                    // This should work for the rest
header('Content-Disposition: attachment; filename="'.basename("excelfile.csv").'"');

echo 
$header."\n".$data;
?>
_____________________________________


תגובה ללא ציטוט תגובה עם ציטוט חזרה לפורום
תגובה

כלי אשכול חפש באשכול זה
חפש באשכול זה:

חיפוש מתקדם
מצבי תצוגה דרג אשכול זה
דרג אשכול זה:

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

קוד vB פעיל
קוד [IMG] פעיל
קוד HTML כבוי
מעבר לפורום



כל הזמנים המוצגים בדף זה הם לפי איזור זמן GMT +2. השעה כעת היא 08:48

הדף נוצר ב 0.04 שניות עם 12 שאילתות

הפורום מבוסס על vBulletin, גירסא 3.0.6
כל הזכויות לתוכנת הפורומים שמורות © 2024 - 2000 לחברת Jelsoft Enterprises.
כל הזכויות שמורות ל Fresh.co.il ©

צור קשר | תקנון האתר