jeesite 导出 文件

1.添加按钮

<span style="font-size:18px;"><input id="btnExport" class="btn btn-primary" type="button"  value="导出Excel" /></span>
</pre><pre name="code" class="html">

2.js

                                $("#btnExport").click(
						function() {
							/* 显示一个带"确定"和"取消"按钮的确认消息窗口 */
							top.$.jBox.confirm("确认要导出用户数据吗?", "系统提示", function(
									v, h, f) {
								if (v == "ok") {
									$("#searchForm1").attr("action",
											"${ctx}/wish/wishUser/export");
									$("#searchForm1").submit();
								}
							}, {
								/* 表示第几个按钮为默认按钮,索引从0开始 */
								buttonsFocus : 1
						});
							top.$('.jbox-body .jbox-icon').css('top', '55px');
						});
3.修改控制类
<span style="font-size:18px;">@RequiresPermissions("sys:user:view")
	@RequestMapping(value = "export", method= RequestMethod.POST)
	public String exportFile(WishUser user, HttpServletRequest request, HttpServletResponse response, RedirectAttributes redirectAttributes) {
		try {
			String fileName = "用户数据"+ DateUtils.getDate("yyyyMMddHHmmss")+".xlsx";
			Page<WishUser> page = wishUserService.findPage(new Page<WishUser>(request, response, -1), user);
			new ExportExcel("用户数据", WishUser.class).setDataList(page.getList()).write(response, fileName).dispose();
			return null;
		} catch (Exception e) {
			addMessage(redirectAttributes, "导出用户失败!失败信息:"+e.getMessage());
		}
		return "redirect:" + adminPath + "/sys/user/list?repage";
	}</span>
4.修改实体类 在需要导出的字段get上添加

<span style="font-size:14px;">@Length(min=0, max=128, message="头像url长度必须介于 0 和 128 之间")
<span style="white-space:pre">	</span>@ExcelField(title="头像url", type=1, align=2, sort=1)
<span style="white-space:pre">	</span>public String getAvatar() {
<span style="white-space:pre">		</span>return avatar;
<span style="white-space:pre">	</span>}</span>


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值