getIds方法正是收获已选的要导出的数量的ID

本文实例汇报了Dwz与thinkphp整合下的多少导出到Excel的不二诀窍。分享给我们供我们参照他事他说加以考察。具体方法如下:

其大器晚成主题材料烦扰了自己相当久,终于仍旧要好写JQUE陆风X8Y把它搞掂了,希望能对蒙受同样难题的人具备利于,可以吗,下边正是源代码:

jquery代码如下:复制代码 代码如下:${
//_getIds方法正是得到已选的要导出的数目标ID,设了四个参数selectedIds–已选id的input名称,targetType–>碎片格局,暗许是navTab,假使是dialog的自发性纠正function _getIds(selectedIds,targetType){ var ids=””; var
$box=targetType==”dialog”?$.pdialog.getCurrent():navTab.getCurrentPanel();
$box.find.filter(“[name='”+selectedIds+”‘]”卡塔尔(英语:State of Qatar).each{ var val=$;
ids+=i==0?val:”,”+val;}卡塔尔(قطر‎; return ids; } //导出excel的按钮class=iconn,click时触发 $.click{ //因为这几个艺术直运用到导出到excel
所以这里所需的参数变量作者直接写死了 var targetType=”navTab”; var
selectedIds=”ids”; var
postType=”string”;//批量选用的话,以文件的款型拿到 var
ids=_getIds(selectedIds,targetType卡塔尔(英语:State of Qatar); if{ alertMsg.error.attr; return
false; //alert; }else{ //将获取到的ids 传给后台管理window.open(“__URL__/memberExport/ids/”+ids卡塔尔(قطر‎; } }卡塔尔(قطر‎;
}卡塔尔国;PHP代码如下:复制代码
代码如下://member成员新闻导出到excel public function memberExport(卡塔尔(قطر‎{
$id=$_REQUEST[‘ids’];//获取已选数据的ID //echo $id;
//在这间导出到excel作者并未有动用phpexcel,是投机写的,非常轻便,相信大家都了然是哪些看头,根据自个儿必要活动改善就能够了
$filename=date; header; header;
header(“Cache-Control:must-revalidate,post-check=0,pre-check=0″卡塔尔(قطر‎;
header(“Content-Type:application/force-download”卡塔尔(英语:State of Qatar);
header(“Content-Type:application/vnd.ms-execl;charset=gb2312″卡塔尔(قطر‎;
header(“Content-Type:application/octet-stream”卡塔尔(قطر‎;
header(“Content-Type:application/download”卡塔尔(قطر‎;
header(‘Content-Disposition:attachment;filename=”‘.$filename.’.xls”‘卡塔尔(英语:State of Qatar);
header(“Content-Transfer-Encoding:binary”卡塔尔; if{ $this->error; }else{
$map[‘id’]=array; $title=”用户名t 姓名t 部门t 职务t 身份证t
职称t 学历t 结业时间t 录用时间”; $title=iconv; echo $title;
set_time_limit; $offset= 0; $length=100; $Member = M;
$list=$Member->where->order; if{ $this->error; }else{ foreach{
echo “n”; echo iconv(‘utf-8′,’gbk’,$row[‘username’]).”t”; echo
iconv(‘utf-8′,’gbk’,$row[‘name’]).”t”; echo
iconv(‘utf-8′,’gbk’,$row[‘department’]).”t”; echo
iconv(‘utf-8′,’gbk’,$row[‘zhiwu’]).”t”; echo
iconv(‘utf-8′,’gbk’,$row[‘sfz’]).”t”; echo
iconv(‘utf-8′,’gbk’,$row[‘zhicheng’]).”t”; echo
iconv(‘utf-8′,’gbk’,$row[‘xueli’]).”t”; echo
iconv(‘utf-8′,’gbk’,$row[‘bytime’]).”t”; echo
iconv(‘utf-8′,’gbk’,$row[‘lytime’]).”t”; } $offset+=$length; } } }

期待本文所述对大家基于ThinkPHP框架的PHP程序设计有着扶助。

相关文章

发表评论

电子邮件地址不会被公开。 必填项已用*标注

*
*
Website