However, according to my test, if you do not delete a place, the generated document will be opened in Excel and an error will be reported!
Delete all strings like this: SS: expandedcolumncount = "5!
Example:
Enter the data and submit it. An xls file is generated.
Another small problem has not been found. This template can only have two pieces of data. If there is more data, it will not work. Dizzy. I still have no idea where to modify it.
In addition, I first wrote formvalidate. php and report. php together, and the result was no result!
Write separately, and the result will be displayed!
Report. phpCopyCodeThe Code is as follows: <? PHP
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. 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; filenameappsreport.xls ");
$ GMT-> display ('report ');
}
?>
header ("cache-control: Public");
This must be added. Otherwise, an error occurs in IE.