ruoyi框架 自定义导出Excel

js:

function exportExcel() {
    $.ajax({
        url: prefix + "/export",
        async: false,
        type: "post",
        data: {
            modelId: $("#modelId").val(),
            groupName: $("#groupName").val()
        },
        success: function (r) {
            if (r.code == '0') {
                // 下载创建好的excel
                window.location.href = ctx + "common/download?fileName=" + r.msg + "&delete=true";
            }
        }
    })
}

 

controller:

@PostMapping("/export")
@ResponseBody
public AjaxResult export(WmStock wmStock, HttpServletRequest request, HttpServletResponse response) {
    List list = wmStockService.selectWmStockList(wmStock);
    ExcelUtil util = new ExcelUtil(WmStock.class);
    return util.exportExcel(list, "食材库存");
}

你可能感兴趣的:(ruoyi,java)