excel模板先设置批注(就是对应一个list在excel中 循环取值)
html页面(简单块)
导出
余额汇总表
js代码(涉及重点)
function excelExportAll() {
//类型选中得值
var selectVal = $('#code').val();
//关键字
var sq = $("#sqSearch").val();
var end = $("#endPicker").val();
window.location.href = BaseUtil.getCxtPath() + "/flow/export?code=" + selectVal + "&sq=" + sq + "&end=" + end;
}
ChangePage.prototype.init = function () {
$('.change_infor').click(function () {
$('#exporta').show();
$('.rjz_wrepper').show();
$('.change_infor').css({'background': '#2d7ec4'})
})
}
new ChangePage();
后台Java代码
@RequestMapping(value = "/export")
public void export(String code, String sq, String end, HttpServletRequest request, HttpServletResponse response) {
log.info("Parameter---{}---{}---Method---export", code, sq);
User currentUser = LoginUtil.getCurrentUser(request);
String currentUserName = currentUser.getUserLoginName();
CompanyVo companyVo = rpcCompanyService.get(sq);
String sign = "";
List authCodeList = new ArrayList<>();
SignVo codeAuthList = this.getCodeAuthList(request);
if(!ObjectUtils.isEmpty(codeAuthList)) {
sign = codeAuthList.getSign();
authCodeList = codeAuthList.getAuthCodeList();
}
List
JxlsUtils工具类中方法
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.jxls.common.Context;
import org.jxls.expression.JexlExpressionEvaluator;
import org.jxls.transform.Transformer;
import org.jxls.util.JxlsHelper;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.net.URLEncoder;
import java.text.SimpleDateFormat;
import java.util.*;
@Slf4j
public class JxlsUtils {
/**
*
* 自定义excel模板导出excel-浏览器导出
*
*
*
* @param templateExcelURL
* excel模板路径(包含至excel文件名)
* @param customeExcelName
* 自定义导出的excel文件名称(默认名称:Excel+年月日时分秒)
* @param list
* 导出数据的List
*/
public static void exportExcel(String templateExcelURL, String customeExcelName,List
模板导出功能记录(zijin)