-
Junior Member
header setting
hi every body.
I want to download an excel file in php.it has 3 sheet with some row and col.
I use this code to do it:
header('Pragma: public');
header('Cache-Control: no-store, no-cache, must-revalidate'); header('Cache-Control: pre-check=0, post-check=0, max-age=0');
header ("Pragma: no-cache");
header("Expires: 0");
header('Content-Transfer-Encoding: none');
header("Content-type: application/x-msexcel");
header("Content-disposition: attachment; filename=MapFeaturesExcel.xls");
readfile("$Folder / $export_file");
exit(0);
but after I look MapFeaturesExcel.xls I see only one sheet,and all of data show in one cell.it is very different from the source file.where is my wrong?
-
Junior Member
Re: header setting
What you want??
1) copy data form excel file to database
2) database to excel file
-
Junior Member
Re: header setting
i give code,which can export sql data to exel file(csv format)...
$SQL="Select * from student";
$tot=mysql_query($SQL,$rs);
if($tot==0)
{
$msg="No records found with such roll number"."
"."Please enter valid starting & ending roll no.!";
export_show($msg);
print "$data[roll_no]\"";
die();
}
header("Content-type: text/html");
header("Content-Disposition: attachment; filename=student_data.csv");
print "NAME, AGE, SEX, COUNTRY, ABOUT, IMAGE_PATH, EMAIL, QUALIFICATION1, QUALIFICATION2, QUALIFICATION3, QUALIFICATION4, ROLL_NO, DATE_JOIN";
while($data = mfa($rs))
{
$row="$data[name]";
$row.=",\"$data[age]\"";
$row.=",\"$data[sex]\"";
$row.=",\"$data[country]\"";
$row.=",\"$st[about]\"";
$row.=",\"$data[image_path]\"";
$row.=",\"$data[email]\"";
$row.=",\"$data[qualification1]\"";
$row.=",\"$data[qualification2]\"";
$row.=",\"$data[qualification3]\"";
$row.=",\"$data[qualification4]\"";
$row.=",\"$data[roll_no]\"";
$row.=",\"$data[date_join]\"";
print $row."\n";
}
-
Junior Member
Re: header setting
header("Content-type: text/html");
header("Content-Disposition: attachment; filename=filename.csv");
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules