However, according to my experiment, if you do not delete a place, the resulting document opened in Excel, it will be an error!
Delete all strings like this: ss:expandedcolumncount= "5" on the line!
Example:
Just fill in some data, then submit, will generate an XLS file.
There is a small problem did not find out, this template, can only have two data, many also not, Halo, has not found to change where it.
In addition, I began to put formvalidate.php and report.php together to write, the result is no result!
Separate write, there will be results!
report.php
Copy Code code as follows:
<?php
Include '.. /common.inc.php ';
$token = $_post[' token '];
if (Gtoken::istoken ($token, ' ') ') {
$names = $_post[' name '];
$birthdays = $_post[' birthday '];
$phones = $_post[' phone '];
$sexs = $_post[' sex '];
$emails = $_post[' email '];
$scoreAs = $_post[' Scorea '];
$scoreBs = $_post[' Scoreb '];
$scoreCs = $_post[' Scorec '];
$list = Array ();
$score = Array ();
for ($i =0; $i <sizeof ($names); $i + +) {
$arr = Array (
' Name ' => $names [$i],
' Sexs ' => $sexs [$i],
' Birthday ' => $birthdays [$i],
' Email ' => $emails [$i],
' Phone ' => $phones [$i]
);
Array_push ($list, $arr);
Unset ($arr);
$arr = Array (
' Name ' => $names [$i],
' Scorea ' => $scoreAs [$i],
' Scoreb ' => $scoreBs [$i],
' Scorec ' => $scoreCs [$i]
);
Array_push ($score, $arr);
Unset ($arr);
}
Include '.. /lib/smarty/smarty.class.php ';
$GMT = gsmarty::getinstance (' test ');
$gmt->assign_by_ref ("list", $list);
$gmt->assign_by_ref (' score ', $score);
Header ("Cache-control:public");
Header (' Content-type:application/vnd.ms-excel ');
Header ("content-disposition:attachment; Filename=report.xls ");
$gmt->display (' the ');
}
?>
Header ("Cache-control:public");
This must be added, otherwise, there will be an error in IE.