java前台传参后台条件导出 excel,及导出的excel 通用工具类

需求:

前台要导出excel表格,开始用的bootstrap table的tableExport.js插件导出但是只能导出当前页的数据,so 又改到了后台导出(悲催)

 

导出按钮:

<button type="button" onClick ="supplierOutIncheckExport()">盘库单报(总部)表</button>

JavaScript代码:

function supplierOutIncheckExport(){
    var url =inventoryObj.initStoreInventorycheckExportUrl;//请求后台要导出的地址
	//构建一个虚拟的form 表单并设置表单ID和名称提交方式等
    exportForm = document.createElement("form");
    exportForm.setAttribute('id','StorageInventoryVo')
    exportForm.setAttribute('name','StorageInventoryVo');
    exportForm.setAttribute("action", url);
    exportForm.setAttribute("contentType", 'application/x-xls');
    exportForm.setAttribute("hidden", true);
    exportForm.setAttribute("method", "post");
	//构建一个虚拟的input框并设置属性类型和值,并添入form表单中
    var userId = document.createElement("input");
    userId.type = "text";
    userId.name = "staffId";
    userId.value = currentUser.userId;
    exportForm.appendChild(userId);
    //构建一个虚拟的input框并设置属性类型和值,并添入form表单中
	var fileName = document.createElement("input");
    fileName.type = "text";
    fileName.name = "fileName";
    fileName.value = "库盘单(总部)报表.xls";
    exportForm.appendChild(fileName);
	//表单提交
    document.body.appendChild(exportForm);
    exportForm.submit();
}

java后台代码:

/**
	*
	* @Author: ruanyanghui
	* @Company: xxxx
	* @Description: 导出实时库存
	* @date 2018/12/6 14:35
	*/
	@PostMapping("/storageexport")
	public void getstorageexport(StorageInventoryVo vo, HttpServletResponse response) {
		vo = vo.getParams();
		St
  • 4
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值