However, according to my experiments, if you do not delete a place and the generated document is opened in excel, an error will be reported!
Delete all strings like this: ss:ExpandedColumnCount="5" and that's it!
Example:
Fill in some data and submit, an xls file will be generated.
There is still a small problem that I haven’t found out yet. This template can only have two pieces of data, not more. I’m dizzy. I haven’t found where to modify it yet.
In addition, I initially wrote formValidate.php and report.php together, but there was no result!
Write it separately and you will get the result!
report.php
Copy code The code is 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< 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('report');
}
?>
header("Cache-Control: public ");
This must be added, otherwise an error will occur under IE.
http://www.bkjia.com/PHPjc/319276.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/319276.htmlTechArticleHowever, according to my experiments, if you do not delete a place and open the generated document with excel, it will An error was reported! Delete all strings like this: ss:ExpandedColumnCount="5" and that's it...