不过,跟据我的试验,如果你不删除一个地方,生成的文档用 excel 打开,是会报错的!
删除所有像这样的串: ss:expandedcolumncount="5" 就行了!
示例:
随便填点数据,然后提交,会生成一份 xls 文件。
还有一个小问题没有找出来,这个模板,只能有两笔数据,多了也不行,晕,还没有找到要修改哪里呢。
另外,我开始是把 formvalidate.php 和 report.php合在一起写的,结果是没有结果!
分开写,就有结果了!
report.php
<?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/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");
这一定要加,不然的话,在ie下会发生错误。
如对本文有疑问,
点击进行留言回复!!
相关文章:
-
-
-
-
-
-
-
-
-
管理后台无限级菜单
管理后台菜单遍历很久就想做一个通用的管理后台出来,一直太懒没做,今天开始粗略搞了一下,只是先把框架搭建好,菜单栏...
[阅读全文]
-
桥接模式学习总结
桥接模式引言假如一个系统需要加入报表模块,主要的开发点是数据的获取和报表的显示方式。数据的获取可能是从系统数据库...
[阅读全文]
-
网友评论