Dwz与thinkphp整合下的数据导出到Excel实例_php实例
本文实例讲述了Dwz与thinkphp整合下的数据导出到Excel的方法。分享给大家供大家参考。具体方法如下:
这个问题困扰了我很久,终于还是自己写JQUERY把它搞掂了,希望能对遇到同样问题的人有所帮助,好吧,下面就是源代码:
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("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代码如下:
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;
}
}
}
希望本文所述对大家基于ThinkPHP框架的PHP程序设计有所帮助。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











0.What does this article do? We propose DepthFM: a versatile and fast state-of-the-art generative monocular depth estimation model. In addition to traditional depth estimation tasks, DepthFM also demonstrates state-of-the-art capabilities in downstream tasks such as depth inpainting. DepthFM is efficient and can synthesize depth maps within a few inference steps. Let’s read about this work together ~ 1. Paper information title: DepthFM: FastMonocularDepthEstimationwithFlowMatching Author: MingGui, JohannesS.Fischer, UlrichPrestel, PingchuanMa, Dmytr

The performance of JAX, promoted by Google, has surpassed that of Pytorch and TensorFlow in recent benchmark tests, ranking first in 7 indicators. And the test was not done on the TPU with the best JAX performance. Although among developers, Pytorch is still more popular than Tensorflow. But in the future, perhaps more large models will be trained and run based on the JAX platform. Models Recently, the Keras team benchmarked three backends (TensorFlow, JAX, PyTorch) with the native PyTorch implementation and Keras2 with TensorFlow. First, they select a set of mainstream

To run the ThinkPHP project, you need to: install Composer; use Composer to create the project; enter the project directory and execute php bin/console serve; visit http://localhost:8000 to view the welcome page.

ThinkPHP has multiple versions designed for different PHP versions. Major versions include 3.2, 5.0, 5.1, and 6.0, while minor versions are used to fix bugs and provide new features. The latest stable version is ThinkPHP 6.0.16. When choosing a version, consider the PHP version, feature requirements, and community support. It is recommended to use the latest stable version for best performance and support.

Facing lag, slow mobile data connection on iPhone? Typically, the strength of cellular internet on your phone depends on several factors such as region, cellular network type, roaming type, etc. There are some things you can do to get a faster, more reliable cellular Internet connection. Fix 1 – Force Restart iPhone Sometimes, force restarting your device just resets a lot of things, including the cellular connection. Step 1 – Just press the volume up key once and release. Next, press the Volume Down key and release it again. Step 2 – The next part of the process is to hold the button on the right side. Let the iPhone finish restarting. Enable cellular data and check network speed. Check again Fix 2 – Change data mode While 5G offers better network speeds, it works better when the signal is weaker

1. Open the PPT and turn the page to the page where you need to insert the excel icon. Click the Insert tab. 2. Click [Object]. 3. The following dialog box will pop up. 4. Click [Create from file] and click [Browse]. 5. Select the excel table to be inserted. 6. Click OK and the following page will pop up. 7. Check [Show as icon]. 8. Click OK.

The latest video of Tesla's robot Optimus is released, and it can already work in the factory. At normal speed, it sorts batteries (Tesla's 4680 batteries) like this: The official also released what it looks like at 20x speed - on a small "workstation", picking and picking and picking: This time it is released One of the highlights of the video is that Optimus completes this work in the factory, completely autonomously, without human intervention throughout the process. And from the perspective of Optimus, it can also pick up and place the crooked battery, focusing on automatic error correction: Regarding Optimus's hand, NVIDIA scientist Jim Fan gave a high evaluation: Optimus's hand is the world's five-fingered robot. One of the most dexterous. Its hands are not only tactile

I cry to death. The world is madly building big models. The data on the Internet is not enough. It is not enough at all. The training model looks like "The Hunger Games", and AI researchers around the world are worrying about how to feed these data voracious eaters. This problem is particularly prominent in multi-modal tasks. At a time when nothing could be done, a start-up team from the Department of Renmin University of China used its own new model to become the first in China to make "model-generated data feed itself" a reality. Moreover, it is a two-pronged approach on the understanding side and the generation side. Both sides can generate high-quality, multi-modal new data and provide data feedback to the model itself. What is a model? Awaker 1.0, a large multi-modal model that just appeared on the Zhongguancun Forum. Who is the team? Sophon engine. Founded by Gao Yizhao, a doctoral student at Renmin University’s Hillhouse School of Artificial Intelligence.
