Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to export data under the integration of Dwz and thinkphp to Excel

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article introduces the knowledge of "how to export the data under the integration of Dwz and thinkphp to Excel". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

This paper gives an example of the method of exporting data under the integration of Dwz and thinkphp to Excel. Share it with you for your reference. The specific methods are as follows:

The jquery code is as follows:

The copy code is as follows:

$(function () {)

/ / _ getIds method is to get the ID of the selected data to be exported. Set two parameters: selectedIds-- the input name of the selected id, targetType-- > fragment mode. Default is navTab, if it is self-modified by 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

}

/ / triggered when the button class=iconn,click of excel is exported

$(".iconn") .click

Function () {

/ / because this method is directly applied to export to excel, I directly write down the parameter variables needed here.

Var targetType= "navTab"

Var selectedIds= "ids"

Var postType= "string"; / / obtain it in the form of text if you select it in batch

Var ids=_getIds (selectedIds,targetType)

If (! ids) {

AlertMsg.error ($(".iconn") .attr ("warn"))

Return false

/ / alert ("Please select data to export!")

} else {

/ / transfer the acquired ids to the background for processing

Window.open ("_ _ URL__/memberExport/ids/" + ids)

}

});

});

The PHP code is as follows:

The copy code is as follows:

/ / member member information is exported to excel

Public function memberExport () {

$id=$_REQUEST ['ids']; / / get the ID of the selected data

/ / echo $id

/ / I didn't use phpexcel to export to excel here. I wrote it myself. It's very simple. I believe everyone knows what it means. Just modify it according to your own needs.

$filename=date ('Ymurmmurd`)

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 ('illegal operation!')

} else {

$map ['id'] = array (' in',$id)

$title= "user name\ t name\ t department\ t position\ t ID card\ t professional title\ t education\ t graduation time\ t employment time"

$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 ('operation 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

}

}

}

This is the end of the content of "how to export data under the integration of Dwz and thinkphp to Excel". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report