表单向导中导出某张表
来源:互联网 发布:.net域名代表什么 编辑:程序博客网 时间:2024/06/06 01:34
1.先按照Word格式写好一个html:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="X-UA-Compatible" content="IE=7" /> <title>导出Word</title> <meta name="keywords" content="{$SEO['keyword']}"> <meta name="description" content="{$SEO['description']}"> <style type="text/css"> </style></head><body> <div id="PrintA" name="PrintA"> <div class="title" style="text-align: center;font-size: x-large;margin-bottom: 10px;">加入集团申请表(院校)</div> <table class="content" border="1" style="width:50%;margin-left: 25%;border-collapse:collapse;"> <tr> <th style="text-align: center;width: 15%;height: 50px;">单位名称</th> <td colspan="3" style="text-align: center;">南宁市第六职业技术学校</td> <th style="text-align: center;width: 15%;height: 50px;">地址邮编</th> <td style="text-align: center;">南宁市青秀区桃源路64号 530021</td> </tr> <tr> <th style="text-align: center;width: 15%;height: 50px;">法人代表</th> <td colspan="3" style="text-align: center;">李智宁</td> <th style="text-align: center;width: 15%;height: 50px;">网址</th> <td style="text-align: center;">nn6zx.com</td> </tr> <tr> <th rowspan="3" style="text-align: center;width: 15%;height: 50px;">联系人</th> <th style="text-align: center;width: 15%;height: 50px;">姓名</th> <td colspan="2" style="text-align: center;">潘 敏</td> <th style="text-align: center;width: 15%;height: 50px;">职务</th> <td style="text-align: center;">主任</td> </tr> <tr> <th rowspan="2" style="text-align: center;width: 15%;height: 50px;">联系方式</th> <th style="text-align: center;width: 15%;height: 50px;">电话</th> <td style="text-align: center;">2808936</td> <th style="text-align: center;width: 15%;height: 50px;">手机</th> <td style="text-align: center;">18076610580</td> </tr> <tr> <th style="text-align: center;width: 15%;height: 50px;">传真</th> <td style="text-align: center;">2808936</td> <th style="text-align: center;width: 15%;height: 50px;">电子邮箱</th> <td style="text-align: center;">1648474403@qq.com</td> </tr> <tr> <th style="text-align: center;width: 15%;height: 50px;">单位简介</th> <td colspan="5" style="text-align: center;">南宁市第六职业技术学校是一所“国家级重点中职学校”及“国家改革发展示范学校”,学校现开设有计算机、商贸、文秘、机电等七大类17个专业,其中计算机应用、电子商务、会计为自治区级示范专业。现在校学生7800人,教职员工280人,学校现有仙葫和桃源两个校区,校园总面积330亩。 学校先后被评为“全国职业教育先进单位””、“广西中职教育示范特色学校”、“全区中小学(中职学校)德育工作先进单位”“、是“国家级计算机应用专业领域技能型紧缺人才培养培训基地”、“南宁市中等职业教育信息技术专业集团”牵头建设单位,被自治区劳动和社会保障厅等四单位联合授予“技能人才培育突出贡献奖”。</td> </tr> <tr> <th style="text-align: center;width: 15%;height: 50px;">审批意见</th> <td colspan="5" style="text-align: center;"> <p style="margin: 120px 20px 20px 350px">年 月 日</p> </td> </tr> </table> </div></body></html>
2.然后在项目中的相应位置后台加入:
<span style="white-space:pre"></span>/** * 导出word */public function expotWord(){ $dataid=$_GET['dataid']; $name='申请表'; //downloadWord(getWord($dataid), $name.'.doc'); $this->downloadWord($this->getWord($dataid), $name.'.doc'); //<span style="color:#ff0000;">注意,因为这是在v9里面,所以在downloadWord方法前一定要加$this->,不然不能导出</span>}/** * 获取Word格式 */ public function getWord($dataid){$this->db->change_table('form_sqb'); $info=$this->db->select($where=array('dataid'=>$dataid),$data='*'); // echo json_encode($info[0]['addr']);die;//输出某个字段值 $head='<div class="title" style="text-align: center;font-size: x-large;margin-bottom: 10px;">加入集团申请表(院校)</div>'; $table='<table class="content" border="1" style="width:100%;margin-left: 10%;border-collapse:collapse;">'; //word格式 $word='<tr> <th style="text-align: center;width: 10%;height: 50px;font-size:20px;">单位名称</th> <td colspan="3" style="text-align: center;width: 40%;height: 50px;font-size:18px;">'.$info[0]['dwmc'].'</td> <th style="text-align: center;width: 10%;height: 50px;font-size:20px;">地址邮编</th> <td style="text-align: center;width: 40%;height: 50px;font-size:18px;">'.$info[0]['dzyb'].'</td> </tr> <tr> <th style="text-align: center;width: 10%;height: 50px;font-size:20px;">法人代表</th> <td colspan="3" style="text-align: center;width: 40%;height: 50px;font-size:18px;">'.$info[0]['frdb'].'</td> <th style="text-align: center;width: 10%;height: 50px;font-size:20px;">网址</th> <td style="text-align: center;width: 40%;height: 50px;font-size:18px;">'.$info[0]['wz'].'</td> </tr> <tr> <th rowspan="3" style="text-align: center;width: 10%;height: 210px;font-size:20px;">联系人</th> <th style="text-align: center;width: 10%;height: 50px;font-size:20px;">姓名</th> <td colspan="2" style="text-align: center;width: 30%;height: 50px;font-size:18px;">'.$info[0]['name'].'</td> <th style="text-align: center;width: 10%;height: 50px;font-size:20px;">职务</th> <td style="text-align: center;width: 40%;height: 50px;font-size:18px;"">'.$info[0]['zw'].'</td> </tr> <tr> <th rowspan="2" style="text-align: center;width: 10%;height: 50px;font-size:20px;">联系方式</th> <th style="text-align: center;width: 10%;height: 50px;font-size:20px;">电话</th> <td style="text-align: center;width: 20%;height: 50px;font-size:18px;">'.$info[0]['phone'].'</td> <th style="text-align: center;width: 10%;height: 50px;font-size:20px;">手机</th> <td style="text-align: center;width: 40%;height: 50px;font-size:18px;">'.$info[0]['mobile'].'</td> </tr> <tr> <th style="text-align: center;width: 10%;height: 50px;font-size:20px;">传真</th> <td style="text-align: center;width: 20%;height: 50px;font-size:18px;">'.$info[0]['fax'].'</td> <th style="text-align: center;width: 10%;height: 50px;font-size:20px;">电子邮箱</th> <td style="text-align: center;width: 40%;height: 50px;font-size:18px;">'.$info[0]['email'].'</td> </tr> <tr> <th style="text-align: center;width: 10%;height: 400px;font-size:20px;">单位简介</th> <td colspan="5" style="text-align: left;width: 90%;height: 400px;font-size:18px;line-height:35px;"> '.$info[0]['brief'].'</td> </tr> <tr> <th style="text-align: center;width: 10%;height: 200px;font-size:20px;">审批意见</th> <td colspan="5" style="text-align: center;width: 90%;height: 50px;font-size:18px;"> <p style="margin: 120px 20px 20px 250px;font-size:18px;">年 月 日</p> </td> </tr> </table>'; return $head.$table.$word; }/*** 导出word*/ public function downloadWord($content, $file='newfile.xls'){ header("Cache-Control: no-cache, must-revalidate"); header("Pragma: no-cache"); header("Content-Type: application/octet-stream"); header("Content-Disposition: attachment; filename=$file"); $ext = substr(end(explode('.', $file)), 0, 3); switch($ext){ case 'doc' : $html = '<html xmlns:v="urn:schemas-microsoft-com:vml"xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml"xmlns="http://www.w3.org/TR/REC-html40">'; $html .= '<head></head>'; break; case 'xls': $html = '<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office"xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40">'; $html .= '<head><!--[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet><x:Name></x:Name><x:WorksheetOptions><x:Selected/></x:WorksheetOptions></x:ExcelWorksheet></x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]--></head>'; } echo $html . '<body>'.$content .'</body></html>';}3.再在相应位置引用:
<td align="center"><a href="?m=formguide&c=formguide_info&a=expotWord&formid=<?php echo $formid?>&dataid=<?php echo $d['dataid']?>">导出</a></td>
4.相关插件链接:
phpcms v9导出excel插件
0 0
- 表单向导中导出某张表
- VC中属性表单和向导的创建
- MFC中属性表单,向导,Tab控件演示实例
- phpcms v9表单向导中怎么加入验证码
- MFC中属性表单和向导对话框的使用
- phpcms v9表单向导中怎么加入验证码
- PHPCMS v9表单向导中怎么加入验证码
- 属性表单与向导
- phpcmsv9表单向导运用
- 前端相关-表单向导
- phpcms自定义表单向导
- phpcms表单向导设置
- PHP表单向导设置
- exp 导出向导使用方法
- vc创建属性表单向导
- 实现表单式的向导
- 使用Gallery创建向导表单
- 基于Bootstrap的表单向导
- hive关系运算详解
- 操作实践总结
- sql server 2008 r2安装时的服务器配置。
- HDU 1787GCD Again
- Android应用性能优化系列视图篇——隐藏在资源图片中的内存杀手
- 表单向导中导出某张表
- 列关于java 中的 wait()方法和 sleep()方法的区别描述错误的是?
- 从oracle导入到MongoDB-csv乱码-MongoDB3.2.x
- 理解伪元素 :before 和 :after
- CSDN Markdown Learning
- HDU 2588 GCD
- 微信小程序开发(一)之Hello World!
- scala基础3 —— 表达式和控制结构
- Unity3D自学笔记——脚本开发中的3D数学