05-29-2008, 04:08 AM
|
#1 (permalink)
|
|
The Addict
Join Date: Jan 2008
Location: los angeles
Posts: 309
Thanks: 44
|
exporting mysql db to excel
i tried this script below but when i run it this is the error i keep receiving, how can i fix it?? thanks
ERROR
Code:
Warning: Cannot modify header information - headers already sent by (output started at localhost/status/exportxls.php:1) in localhost/status/exportxls.php on line 44
Warning: Cannot modify header information - headers already sent by (output started at localhost/status/exportxls.php:1) in localhost/status/exportxls.php on line 45
Warning: Cannot modify header information - headers already sent by (output started at localhost/status/exportxls.php:1) in localhost/status/exportxls.php on line 46
Warning: Cannot modify header information - headers already sent by (output started at localhost/status/exportxls.php:1) in localhost/status/exportxls.php on line 47
Warning: Cannot modify header information - headers already sent by (output started at localhost/status/exportxls.php:1) in localhost/status/exportxls.php on line 48
Warning: Cannot modify header information - headers already sent by (output started at localhost/status/exportxls.php:1) in localhost/status/exportxls.php on line 49
Warning: Cannot modify header information - headers already sent by (output started at localhost/status/exportxls.php:1) in localhost/status/exportxls.php on line 50
Warning: Cannot modify header information - headers already sent by (output started at localhost/status/exportxls.php:1) in localhost/status/exportxls.php on line 51
���������������Domain Listing�������domain������client���������� �date_prom������status������devsite ������ready������exist_customization����� �new_custom�� ����comments�� ����version������priority������status_desc�� ����customization_yn�����������������
���������
���������������� ������No�������������none������none�� ������� ����� ������10��������� �������������������������heritage��������
������
������� ������No ������no�������������manager module *�� ���"�get someone to add the 300 patches�� ����� ������10��������� ������������������������ �CPA Actuaries���������������
CODE
Code:
<?php
include("config.php");
$result=mysql_query("select * from tbl_clone order by id");
#=============================================
# Create Function for XLS#=============================================
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 Data
#=============================================
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=status.xls");
header("Content-Transfer-Encoding: binary");
xlsBOF();
#=============================================
# Begin Export
# NOTE: FIRST: ROW || SECOND: COLUMN
#=============================================
/*
=========== HEADER DATA ===============
*/
xlsWriteLabel(0,0,"Domain Listing");
// Make column labels. (at line 3)
xlsWriteLabel(2,0,"domain");
xlsWriteLabel(2,1,"client");
xlsWriteLabel(2,2,"payrol");
xlsWriteLabel(2,3,"date_prom");
xlsWriteLabel(2,4,"status");
xlsWriteLabel(2,5,"devsite");
xlsWriteLabel(2,6,"ready");
xlsWriteLabel(2,7,"exist_customization");
xlsWriteLabel(2,8,"new_custom");
xlsWriteLabel(2,9,"comments");
xlsWriteLabel(2,10,"version");
xlsWriteLabel(2,11,"priority");
xlsWriteLabel(2,12,"status_desc");
xlsWriteLabel(2,13,"customization_yn");
#=============================================
# LOOP and spit out info from db
#=============================================
$xlsRow = 14;
while($row=mysql_fetch_array($result)){
xlsWriteNumber($xlsRow,0,$row['domain']);
xlsWriteLabel($xlsRow,1,$row['client']);
xlsWriteLabel($xlsRow,2,$row['payrol']);
xlsWriteLabel($xlsRow,3,$row['date_prom']);
xlsWriteLabel($xlsRow,4,$row['status']);
xlsWriteLabel($xlsRow,5,$row['devsite']);
xlsWriteLabel($xlsRow,6,$row['ready']);
xlsWriteLabel($xlsRow,7,$row['exist_customization']);
xlsWriteLabel($xlsRow,8,$row['new_custom']);
xlsWriteLabel($xlsRow,9,$row['comments']);
xlsWriteLabel($xlsRow,10,$row['version']);
xlsWriteLabel($xlsRow,11,$row['priority']);
xlsWriteLabel($xlsRow,12,$row['status_desc']);
xlsWriteLabel($xlsRow,13,$row['customization_yn']);
$xlsRow++;
}
xlsEOF();
exit();
mysql_close();
?>
ps: i'm using office 2007 to open the file if that makes a diff.
__________________
no signature set
|
|
|
|