However, according to my experiment, if you do not delete a place, the generated document opened with Excel, will be error!
Delete all the strings like this: ss:expandedcolumncount= "5" on the line!
Example:
Fill in the data, then submit, generate an XLS file.
There is a small problem not to find out, this template, can only have two data, more also not, dizzy, have not found to modify where it.
In addition, I started to put formvalidate.php and report.php together to write, the result is no result!
Write separately, there is the result!
report.php
Copy the Code code as follows:
Include '. /common.inc.php ';
$token = $_post[' token '];
if (Gtoken::istoken ($token, ' Report ')) {
$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
$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 (' report ');
}
?>
Header ("Cache-control:public");
This must be added, otherwise, an error will occur under IE.
The above describes the Shimokita glory days PHP Smarty generated Excel document code, including the Shimokita glory days content, I hope to be interested in PHP tutorial friends helpful.