toexcel.php
资源名称:minierp.rar [点击查看]
上传用户:yantgcom
上传日期:2013-07-19
资源大小:478k
文件大小:2k
源码类别:
MySQL数据库
开发平台:
PHP
- <?php
- header("Content-Type: application/vnd.ms-excel");
- header("Content-Disposition: attachment; filename=view_list.xls");
- header("Pragma: no-cache");
- header("Expires: 0");
- include ("../inc/db.php");
- include ("../inc/phpmkrfn.php");
- $t_AUTOID=$_GET['AUTOID'];
- if (empty($t_AUTOID)){$t_AUTOID=0;};
- $conn = phpmkr_db_connect(HOST, USER, PASS, DB, PORT);
- $sSql ="select shdmast.*,accounts.ACC01 from shdmast LEFT JOIN accounts ON shdmast.SHM02 = accounts.ID where shdmast.AUTOID= $t_AUTOID ";
- $rs = phpmkr_query($sSql,$conn) or die("Failed to execute query: " . phpmkr_error() . '<br>SQL: ' . $sSql);
- //xlsBOF(); // begin Excel stream
- $row = mysql_fetch_array($rs, MYSQL_ASSOC);
- $deltid=$row[SHMID]; //送货明细编号
- echo $row[ACC01]."t";
- echo $row[SHM01]."t";
- echo $row[SHMID]."t";
- $sSql ="select * from shddelt where shdid='".$deltid."'";
- $rs = phpmkr_query($sSql,$conn) or die("Failed to execute query: " . phpmkr_error() . '<br>SQL: ' . $sSql);
- $i=1; //ROWNUM 行数
- while($row = mysql_fetch_array($rs, MYSQL_ASSOC)){
- //echo $row[SHD02];
- $i=$i+1;
- };
- //xlsWriteLabel(0,0,"This is a label"); // write a label in A1, use for dates too
- //xlsWriteNumber(0,1,9999); // write a number B1
- //xlsEOF(); // close the stream
- 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 to write a label (text) into Row, Col
- function xlsWriteLabel($Row, $Col, $Value ) {
- $L = strlen($Value);
- echo pack("ssssss", 0x204, 8 + $L, $Row, $Col, 0x0, $L);
- echo $Value;
- return;
- }
- ?>