失效链接处理 |
java导出Excel文件 PDF 下载
本站整理下载:
相关截图:
主要内容:
1,导入依赖: <!-- poi --> <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi</artifactId> <version>3.15</version> </dependency> <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi-ooxml-schemas</artifactId> <version>3.15</version> </dependency> <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi-ooxml</artifactId> <version>3.15</version> </dependency> 2,application.yml: file: #文件保存地址 (线上需要配置静态资源路径/static/) save: path: D:/files/export/static/ #文件下载地址 base: path: "http://tzstatistics.95013.com:10008/static/" 3,html vue @click导出按钮 <div class="btn-group" role="group" aria-label="..."> <a class="btn btn-info" style="border-radius: 50px 50px 50px 50px; color: #fff" @click="exportGrid">导出</a> </div> 4,js jpGrid+vue的methods: // 导出文件
exportGrid: function () { vm.q.startTime = $("#start_time").val(); if (isNull(vm.q.startTime)) { alert("请选择月份"); return; }//获取列名 var colNames = $("#jqGrid").jqGrid('getGridParam', 'colNames').toString(); var params = { 'colNames': colNames, 'startTime': vm.q.startTime, };params = JSON.stringify(params); $.ajax({ url: '../statistic/bind/mouthExport', dataType: 'json', type: 'POST', // contentType : false, cache: false, async: true, // timeout: 10000, data: params, beforeSend: function () { parent.layerIndex = parent.layer.msg('正在导出,请稍后...', { icon: 16 , shade: 0.5 , time: 1000 * 60 * 60 }); },complete: function () { parent.layer.close(parent.layerIndex); },success: function (r) { if ("200" == r.status) { var a = document.createElement("a");
a.href = r.data; a.click(); vm.reload(); alert("导出成功"); return; } else { parent.layer.alert(r.msg, { icon: 2 , shade: 0.5 }); return; } // else }, /// success error: function (e) { alert("请求出错"); } }); // ajax }, // exportGrid
|