澳门威利斯人_威利斯人娱乐「手机版」

来自 澳门威利斯人 2019-08-10 16:52 的文章
当前位置: 澳门威利斯人 > 澳门威利斯人 > 正文

php不使用插件导出excel的简单方法,Dwz与thinkphp整

本文实例陈述了Dwz与thinkphp整合下的数目导出到Excel的主意。分享给大家供大家参谋。具体方法如下:

php导入到excel乱码是因为utf8编码在xp系统不支持具有utf8编码转码一下就周到化解了
utf-8编码案例 Php代码

复制代码 代码如下:

以此标题找麻烦了自己相当久,终于依然本人写JQUEPRADOY把它搞掂了,希望能对境遇一样题指标人抱有援救,好呢,上边就是源代码:

复制代码 代码如下:

$filename=date("Y年m月d日")."数据音信总括结果.xls";     //文件名
$ua = $_SERVER["HTTP_USER_AGENT"];        //汉语文件名不乱码
if (preg_match("/MSIE/", $ua)) {
      $filename=urlencode($filename);
} else if (preg_match("/Firefox/", $ua)) {
      $filename=$filename;
} else {
      $filename=urlencode($filename);
}
header("Content-type:application/vnd.ms-excel");   //输出excel头
header("Content-Disposition:filename=".$filename);
$n = iconv('utf-8', 'gbk', '11');       //设置excel表格列
$t = iconv('utf-8', 'gbk', '22');
$k = iconv('utf-8', 'gbk', '33');
$s = iconv('utf-8', 'gbk', '44');
$r= iconv('utf-8', 'gbk', '55');
$a= iconv('utf-8', 'gbk', '66');

jquery代码如下:

<?php
header("Content-Type: application/vnd.ms-excel; charset=UTF-8");
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Content-Type: application/force-download");
header("Content-Type: application/octet-stream");
header("Content-Type: application/download");
header("Content-Disposition: attachment;filename=11.xls ");
header("Content-Transfer-Encoding: binary ");
?> 

echo "{$n}t";
echo "{$t}t";
echo "{$k}t";
echo "{$s}t";
echo "{$r}t";
echo "{$a}tn";

复制代码 代码如下:

Php代码

      
foreach($a as $kk=>$pp){          //对每列些数据
foreach($pp['child'] as $k=>$p){
echo iconv("utf-8", "gbk//IGNORE", $pp['u']."t");
echo iconv("utf-8", "gbk//IGNORE", $p['u']."t");
echo iconv("utf-8", "gbk//IGNORE", $p['s']."t");
echo iconv("utf-8", "gbk//IGNORE", $p['t']."t");
echo iconv("utf-8", "gbk//IGNORE", $p['c']."t");
echo iconv("utf-8", "gbk//IGNORE", $p['t']."tn");
}
}

$(function(){ 
 
        //_getIds方法正是获得已选的要导出的数码的ID,设了八个参数selectedIds--已选id的input名称,targetType-->碎片格局,暗许是navTab,要是是dialog的自发性修改 
function _getIds(selectedIds,targetType){ 
        var ids=""; 
        var $box=targetType=="dialog"?$.pdialog.getCurrent():navTab.getCurrentPanel(); 
        $box.find("input:checked").filter("[name='" selectedIds "']").each(function(i){ 
 
            var val=$(this).val(); 
            ids =i==0?val:"," val;}); 
            return ids; 
        } 
        //导出excel的按钮 class=iconn,click时触发 
$(".iconn").click( 
function(){ 
//因为那个点子直运用到导出到excel 所以这里所需的参数变量作者直接写死了 
var targetType="navTab"; 
var selectedIds="ids"; 
var postType="string";//批量选拔的话,以文件的样式猎取 
var ids=_getIds(selectedIds,targetType); 
if(!ids){ 
alertMsg.error($(".iconn").attr("warn")); 
return false; 
//alert("请接纳要导出的数目!"); 
}else{ 
//将获得到的ids 传给后台管理 
window.open("__URL__/memberExport/ids/" ids); 

 
}); 
});

复制代码 代码如下:

数组格式为

PHP代码如下:

<?   
$filename="php导入到excel-utf-8编码";   
$filename=iconv("utf-8", "gb2312", $filename);   
echo $filename;   
?>  

复制代码 代码如下:

复制代码 代码如下:

gbk编码案例 Php代码

Array
(
    [0] => Array
        (
[unitid] => 1234
[u] => aaa
[fid] => 1000
[shengid] => 1000
[shiid] => 0
[xianid] => 0
[rid] => 2
[orders] => 50
[sys_createuid] => 1
[sys_createtime] => 1383556976
[sys_updateuid] => 1
[sys_updatetime] => 1389853763
[child] => Array
(
[0] => Array
(
    [unitid] => 1035
    [u] => bbb
    [fid] => 1000
    [shengid] => 1000
    [shiid] => 0
    [xianid] => 0
    [rid] => 2
    [orders] => 50
    [sys_createuid] => 1
    [sys_createtime] => 1383556976
    [sys_updateuid] => 1
    [sys_updatetime] => 1389853763
    [funitname] =>
    [s] => 6
    [t] => 1
    [c] => 1
    [t] => 2
)
           [4] => Array
(
    [u] => 合计
    [s] => 8
    [t] => 1
    [c] => 3
    [t] => 3
))))

//member成员新闻导出到excel 
public function memberExport(){ 
    $id=$_REQUEST['ids'];//获取已选数据的ID 
    //echo $id; 
 
//在此间导出到excel我未有使用phpexcel,是投机写的,很轻松,相信大家都理解是怎么意思,依照本人必要活动修改就行了 
    $filename=date('Y-m-d'); 
    header("Pragma:public"); 
header("Expires:0"); 
header("Cache-Control:must-revalidate,post-check=0,pre-check=0"); 
header("Content-Type:application/force-download"); 
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"'); 
header("Content-Transfer-Encoding:binary"); 
if(!$id){ 
$this->error('违法操作!'); 
}else{ 
 
$map['id']=array('in',$id); 
$title="用户名t 姓名t 部门t 职务t 身份证t 职称t 学历t 结束学业时间t 录用时间"; 
$title=iconv('utf-8','gbk',$title); 
echo $title; 
set_time_limit(0); 
   $offset= 0; 
   $length=100; 
$Member = M('Member'); 
$list=$Member->where($map)->order('id desc')->select(); 
if(!$list){ 
$this->error('操作错误!'); 
}else{ 
foreach($list as $key=>$row){ 
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; 


}

复制代码 代码如下:

你大概感兴趣的篇章:

  • php导入导出excel实例
  • 依靠PHP导出Excel的小经验 完美消除乱码难点
  • 使用phpexcel把excel导入数据库和多少库导出excel完成
  • php导出excel格式数据难题
  • PHP导出EXCEL连忙支付指南--PHPEXCEL的运用详解
  • Yii中使用PHPExcel导出Excel的方法
  • phpexcel导出excel的颜料和网页中的颜色展现分歧
  • PHP 导出Excel示例分享
  • PHP达成导出带样式的Excel

愿意本文所述对大家基于ThinkPHP框架的PHP程序设计具备帮助。

<?php
header("Content-Type: application/vnd.ms-excel; charset=UTF-8");
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Content-Type: application/force-download");
header("Content-Type: application/octet-stream");
header("Content-Type: application/download");
header("Content-Disposition: attachment;filename=11.xls ");
header("Content-Transfer-Encoding: binary ");
?> 

你大概感兴趣的稿子:

  • PHP将数据导出Excel表中的实例(投机型)
  • Thinkphp连表查询及数码导出方法身体力行
  • PHP将Excel导入数据库及数据库数据导出至Excel的点子
  • 澳门威尼斯人登陆,浅析PHP数据导出知识点

Php代码

复制代码 代码如下:

0.<?   
0.$filename="php导入到excel-utf-8编码";   
0.echo $filename;   
0.?>  

本文由澳门威利斯人发布于澳门威利斯人,转载请注明出处:php不使用插件导出excel的简单方法,Dwz与thinkphp整

关键词: 澳门威利斯人