" />

久久机这里只有精品,国产69精品一区二区亚洲孕妇,91精品国产综合久久婷婷香蕉,午夜久久久久久电影

最新活動:電腦PC端+手機端+微網(wǎng)站+自適應(yīng)網(wǎng)頁多模板選擇-建站388元起價!??!
當(dāng)前位置:主頁 > 網(wǎng)站建設(shè) > layui框架怎么導(dǎo)出excel表格建站文章

layui框架怎么導(dǎo)出excel表格建站文章

時間:2023-05-27 12:05:27 閱讀: 文章分類: 網(wǎng)站建設(shè) 作者: 網(wǎng)站編輯員

導(dǎo)讀:建站文章建站文章前言:由于工作需要,需要使用到導(dǎo)出excel表格功能,后臺管理使用的是">seo網(wǎng)站關(guān)鍵詞優(yōu)化公司網(wǎng)站建設(shè)

前言:

由于工作需要,需要使用到導(dǎo)出excel表格功能,后臺管理使用的是layui框架。

(學(xué)習(xí)視頻分享:編程入門)

看layui的官網(wǎng)社區(qū)論壇,很多人都說layui自帶的導(dǎo)出功能,只能導(dǎo)出當(dāng)前頁面的數(shù)據(jù)。而且,部分的數(shù)據(jù)都是通過數(shù)據(jù)之間關(guān)聯(lián)表查詢出來的,用layui自帶的導(dǎo)出數(shù)據(jù)會顯示(Object),讓人很頭疼。

所以要用到插件,很簡單,下面的網(wǎng)址,把文件下載。

這個是插件必須用到的文件,注意引入文件的路徑。

在這里給大家提供一個網(wǎng)址,可以來這下載,里面也有教程:https://github.com/wangerzi/layui-excel

給大家看下項目后臺: 就比如訂單號,就是從關(guān)聯(lián)的訂單表中查詢的

直接上代碼:

jsp:

這是一個導(dǎo)出的操作按鈕:

<button type="button" lay-submit="" class="layui-btn layui-btn-warm" lay-filter="uploadImg"> <i class="layui-icon"></i>導(dǎo)出Excel</button> layui.use(['layer', 'form', 'table', 'laydate','jquery'], function () { var $ = layui.jquery, layer = layui.layer, form = layui.form, laydate = layui.laydate, table = layui.table; // 加載框 var loading; loading = layer.load(1, {shade: [0.3, '#fff']}); var tableIns = table.render({ elem: '#tableList', // cellMinWidth: 100, cols: [[ {field: 'sdId', width: 60, title: 'ID', sort: true} , {field: 'sdMoney', width: 87,title: '交易金額',templet:'#cashDepositTpl'} , {field: 'sdTime', minWidth: 87, title: '交易時間'} , {field: 'sdType', width: 300,title: '交易類型', templet: '#sdTypeTpl'} , {field: 'sdWater', minWidth: 120, title: '交易流水編號'} , {field: 'orderFormEntity', minWidth: 68,title: '訂單號', templet: '#orderFormTpl'} ]], url:'${WEB_URL}terraceZL/getList', page: true, even: false, height: 'full-90', request: { pageName: 'page' //頁碼的參數(shù)名稱,默認:page , limitName: 'limit' //每頁數(shù)據(jù)量的參數(shù)名,默認:limit }, limit: 50, done: function (res, curr, count) { layer.close(loading); } }); form.on('submit(uploadImg)', function(data){ loading = layer.load(1, {shade: [0.3, '#fff']}); var $ = layui.jquery; var excel = layui.excel; $.ajax({ url: '${WEB_URL}sellDeal/getTreeList', dataType: 'json', data: { datas:JSON.stringify(data.field) }, success: function(res) { layer.close(loading); layer.msg(res.msg); // 假如返回的 res.data 是需要導(dǎo)出的列表數(shù)據(jù) console.log(res.data);// // 1. 數(shù)組頭部新增表頭 res.data.unshift({sdId: 'ID',sdMoney: '交易金額',sdTime:'交易時間',type:'交易類型',sdWater:'交易流水編號',order:'訂單號'}); // 3. 執(zhí)行導(dǎo)出函數(shù),系統(tǒng)會彈出彈框 excel.exportExcel({ sheet1: res.data }, '平臺流水.xlsx', 'xlsx'); }, error:function(res){ layer.close(loading); layer.msg(res.msg); } }); }); }); Controller: @RequestMapping("/getList") @ResponseBody public Object getList(HttpServletRequest request, Model model) { model.addAttribute("WEB_URL", ServiceUrl.WEB_URL); model.addAttribute("WEB_NAME", ServiceUrl.WEB_NAME); Map<String, Object> paramsMap = JSONObject.parseObject(request.getParameter("datas"), Map.class); if (paramsMap == null) { paramsMap = new HashMap<String, Object>(); } Map<String, Object> map = new HashMap<String, Object>(); try { List<SellDealEntity> mList = new ArrayList<SellDealEntity>(); Integer count = sellDealService.getCountZL(paramsMap); List<SellDealExcelEntity> list = new ArrayList<>(); if (count > 0) { //查詢所有數(shù)據(jù) mList = sellDealService.getListExcel(paramsMap); for (SellDealEntity sellDealEntity : mList) { //自定義一個新實體類,定義好要導(dǎo)出來的字段,把遍歷出來的數(shù)據(jù)存放到一個新的list,因為會出現(xiàn)關(guān)聯(lián)表的數(shù)據(jù) SellDealExcelEntity sellDeal = new SellDealExcelEntity(); sellDeal.setSdId(sellDealEntity.getSdId()); sellDeal.setShopName(sellDealEnti網(wǎng)站建設(shè)ty.getSellEntity().getShopName()); sellDeal.setSdTime(sellDealEntity.getSdTime()); //時間格式可能不對,備用 // DateFormat format=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); // String time = format.format(sellDealEntity.getSdTime()); //根據(jù)類型 set 對應(yīng)的值 switchType(sellDealEntity,sellDeal); sellDeal.setSdWater(sellDealEntity.getSdWater()); //判斷如果訂單是null,就set " - " if (sellDealEntity.getOrderFormEntity()==null){ sellDeal.setOrder("-"); }else { sellDeal.setOrder(sellDealEntity.getOrderFormEntity().getOfOrder()); } list.add(sellDeal); } } map.put("code", 0); map.put("msg", "導(dǎo)出成功"); map.put("count", count); map.put("data", list); }catch (Exception e){ map.put("code", 1); map.put("msg", "導(dǎo)出失敗,請稍后重試!"); } return JSON.toJSON(map); } private void switchType(SellDealEntity sellDealEntity,SellDealExcelEntity sellDeal) { switch (sellDealEntity.getSdType()) { case 0: sellDeal.setType("訂公司網(wǎng)站建設(shè)單收益"); sellDeal.setSdMoney("+"+sellDealEntity.getSdMoney().toString()); break; case 1: sellDeal.setType("售后退款"); sellDeal.setSdMoney("-"+sellDealEntity.getSdMoney().toString()); break; case 2: 網(wǎng)站推廣優(yōu)化seo sellDeal.setType("繳納保證金"); sellDeal.setSdMoney("+"+sellDealEntity.getSdMoney().toString()); break; case 3: sellDeal.setType("保證金充值"); sellDeal.setSdMoney("+"+sellDealEntity.getSdMoney().toString()); break; case 4: sellDeal.setType("保證金扣除"); sellDeal.setSdMoney("-"+sellDealEntity.getSdMoney().toString()); break; case 5: sellDeal.setType("余額提現(xiàn)"); sellDeal.setSdMoney("-"+sellDealEntity.getSdMoney().toString()); break; case 6: sellDeal.setType("保證金提現(xiàn)"); sellDeal.setSdMoney("-"+sellDealEntity.getSdMoney().toString()); break; case 7: sellDeal.setType("保證金提現(xiàn)手續(xù)費"); sellDeal.setSdMoney("+"+sellDealEntity.getSdMoney().toString()); break; case 8: sellDeal.setType("余額提現(xiàn)手續(xù)費"); sellDeal.setSdMoney("+"+sellDealEntity.getSdMoney().toString()); break; case 9: sellDeal.setType("訂單服務(wù)費"); sellDeal.setSdMoney("+"+sellDealEntity.getSdMoney().toString()); break; default: sellDeal.setType("暫無類型"); sellDeal.setSdMoney("0"); } }

關(guān)鍵詞標(biāo)簽: 建站 框架 表格

聲明: 本文由我的SEOUC技術(shù)文章主頁發(fā)布于:2023-05-27 ,文章layui框架怎么導(dǎo)出excel表格建站文章主要講述表格,框架,建站網(wǎng)站建設(shè)源碼以及服務(wù)器配置搭建相關(guān)技術(shù)文章。轉(zhuǎn)載請保留鏈接: http://www.bifwcx.com/article/web_11301.html

我的IDC 網(wǎng)站建設(shè)技術(shù)SEOUC.COM
專注網(wǎng)站建設(shè),SEO優(yōu)化,小程序設(shè)計制作搭建開發(fā)定制網(wǎng)站等,數(shù)千家網(wǎng)站定制開發(fā)案例,網(wǎng)站推廣技術(shù)服務(wù)。
  • 5000+合作客服
  • 8年從業(yè)經(jīng)驗
  • 150+覆蓋行業(yè)
  • 最新熱門源碼技術(shù)文章

    主站蜘蛛池模板: 东丽区| 公安县| 沾化县| 观塘区| 泰来县| 仁化县| 海宁市| 张家港市| 全南县| 唐山市| 泰安市| 绍兴县| 肃南| 西平县| 张家口市| 黎平县| 南昌县| 德格县| 红桥区| 卢湾区| 全州县| 天津市| 珲春市| 仙游县| 南溪县| 三都| 读书| 兴安盟| 海盐县| 三河市| 天台县| 庆元县| 张家口市| 内丘县| 根河市| 峨山| 马鞍山市| 南投市| 吉水县| 大理市| 枣庄市|