$db="(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=192.9.150.7)(PORT=1521)))(CONNECT_DATA=(SID=vis)))";
$c1=OCILogon("apps","apps",$db);
$objParse = OCIParse($c1,$sqlexport);
function xlsBOF() {
echo pack("ssssss", 0x809, 0x8, 0x0, 0x10, 0x0, 0x0);
return;
}
function xlsEOF() {
echo pack("ss", 0x0A, 0x00);
return;
}
function xlsWriteNumber($Row, $Col, $Value) {
echo pack("sssss", 0x203, 14, $Row, $Col, 0x0);
echo pack("d", $Value);
return;
}
function xlsWriteLabel($Row, $Col, $Value ) {
$L = strlen($Value);
echo pack("ssssss", 0x204, 8 + $L, $Row, $Col, 0x0, $L);
echo $Value;
return;
}
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=orderlist.xls ");
header("Content-Disposition: attachment; filename=".basename("ชื่อไฟล์1.xls").";");
header("Content-Transfer-Encoding: binary ");
xlsBOF();
// Make a top line on your excel sheet at line 1 (starting at 0)
// The first number is the row number and the second number is the column, both are start at '0'
// Make column labels. (at line 3)
//xlsWriteLabel(2,0,"No.");
xlsWriteLabel(0,0,"ID");
xlsWriteLabel(0,1,"Transaction Date");
xlsWriteLabel(0,2,"Item No.");
xlsWriteLabel(0,3,"Description");
xlsWriteLabel(0,4,"Transaction Type");
xlsWriteLabel(0,5,"Subinventory");
xlsWriteLabel(0,6,"Locator");
xlsWriteLabel(0,7,"Tranfer Subinv.");
xlsWriteLabel(0,8,"Transfer Locator");
xlsWriteLabel(0,9,"Reference");
xlsWriteLabel(0,10,"Reason");
xlsWriteLabel(0,11,"Creation Date");
xlsWriteLabel(0,12,"Created Name");
$xlsRow = 1;
ด้านล่างมันไม่แสดงจะต้องแก้ยังงัยคับ
// Put data records from mysql by while loop.
while(OCIFetch($objParse)){
xlsWriteLabel($xlsRow,0,OCIResult($objParse,"TRANSACTION_ID"));
xlsWriteLabel($xlsRow,1,OCIResult($objParse,"TRANSACTION_DATE"));
xlsWriteLabel($xlsRow,2,OCIResult($objParse,"ITEM_NUMBER"));
xlsWriteLabel($xlsRow,3,OCIResult($objParse,"ITEM_DESCRIPTION"));
xlsWriteLabel($xlsRow,4,OCIResult($objParse,"TRANSACTION_TYPE_NAME"));
xlsWriteLabel($xlsRow,5,OCIResult($objParse,"SUBINVENTORY_CODE"));
xlsWriteLabel($xlsRow,6,OCIResult($objParse,"LOCATOR_NAME"));
xlsWriteLabel($xlsRow,7,OCIResult($objParse,"TRANSFER_SUBINVENTORY"));
xlsWriteLabel($xlsRow,8,OCIResult($objParse,"TRANSFER_LOCATOR"));
xlsWriteLabel($xlsRow,9,OCIResult($objParse,"TRANSACTION_REFERENCE"));
xlsWriteLabel($xlsRow,10,OCIResult($objParse,"REASON_NAME"));
xlsWriteLabel($xlsRow,11,OCIResult($objParse,"CREATION_DATE"));
xlsWriteLabel($xlsRow,12,OCIResult($objParse,"CREATED_NAME"));
$xlsRow++;
}
xlsWriteLabel($xlsRow,12,$seq);
xlsEOF();