 |
|
|
 |
 |
|
ในบทเรียน..มีครับลองศึกษาดู
|
 |
 |
 |
 |
Date :
10 มิ.ย. 2551 09:00:35 |
By :
เต้ |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ผมลองทำตามบทเรียนแล้วมันไม่ได้อะคับ มันฟ้อง
Cannot modify header information - headers already sent by (output started at C:\AppServ\www\satisfy\admin\mod_quotation\test.php:9)
แล้วมันก็ไม่เด้งตัว box ที่ให้ save เป็น file excel ด้วยคับ งงเลยคับ ส่วนโค๊ดที่ผมลองทำผมใช้ตัวนี้คับ
$token = md5( uniqid(rand(), true ) );
$fname= "../tmp/$token.xls";
$workbook =& new writeexcel_workbook($fname);
$worksheet =& $workbook->addworksheet("summary");
$header =& $workbook->addformat();
$header->set_font("tahoma");
$header->set_bold();
$header->set_align('center');
$header->set_size(12);
$header->set_color('navy');
$header->set_fg_color('silver');
# fix Row 1
$worksheet->freeze_panes(1, 0);
$StrSql = "select Q.`EmpID`, C.`CompanyName_EN`, Q.`project_id`, Q.`Quotation_No`, Q.`quotation_date`,QD.`quo_qty`,QD.`quo_total`, Q.`status`
from $G_table Q
left join `quotation_detail` QD on QD.`Quotation_No` = Q.`Quotation_No` and QD.`Rec_id`=Q.`Rec_id`
left join `customer` C on C.`CustomerID` = Q.`CustomerID`
order by Q.`Quotation_No` asc";
//echo"$StrSql";
$result=mysql_query($StrSql) or die(mysql_error() . ": " . $StrSql);
$worksheet->write(0, 0, "Sales", $header);
$worksheet->write(0, 1, "Customer", $header);
$worksheet->write(0, 2, "Project", $header);
$worksheet->write(0, 3, "NO#", $header);
$worksheet->write(0, 4, "Date", $header);
//$worksheet->write(0, 5, "Product", $header);
$worksheet->write(0, 5, "Qty", $header);
$worksheet->write(0, 6, "Total", $header);
$worksheet->write(0, 7, "status", $header);
$worksheet->set_column('A:B', 5);
$worksheet->set_column('B:C', 30);
$worksheet->set_column('C:D', 25);
$worksheet->set_column('D:E', 15);
$worksheet->set_column('E:F', 12);
$worksheet->set_column('F:G', 30);
$worksheet->set_column('G:H', 5);
$worksheet->set_column('H:I', 10);
//$worksheet->set_column('I:J', 5);
$format1 =& $workbook->addformat();
$format1->set_align('left');
$format1->set_size(11);
$format1->set_font("tahoma");
$columns = 8;
$i=0;
while($row = mysql_fetch_array($result)){
for($j=0; $j<$columns; $j++){
if($j == 7){
$worksheet->write($i+1, $j, $ARRDefine["status"][$row[$j]], $format1);
}else{
$worksheet->write($i+1, $j, $row[$j], $format1);
}
}
$i++;
}
$workbook->close();
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=".basename("$table.xls").";");
header("Content-Transfer-Encoding: binary ");
header("Content-Length: ".filesize($fname));
readfile($fname);
unlink($fname);
exit();
ตัวนี้ที่ทำมัน run ได้ที่เครื่องผมคับ แต่พอขึ้น server มันเป็นหน้าว่างๆคับ ไม่รู้ว่าเป็นเพราะอะไรคับ
|
 |
 |
 |
 |
Date :
10 มิ.ย. 2551 15:03:50 |
By :
maruk |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ปัญหาเดียวกันเลยคับ
ทำที่เครื่องตัวเองได้ปกติ แต่พอเอาขึ้น server มันไม่ขึ้นไรเลย
เมลล์ผม [email protected]
ช่วยชี้แนะด้วยนะคับ ขอบคุณคับ
|
 |
 |
 |
 |
Date :
11 ก.ค. 2551 14:39:13 |
By :
aoiza |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|