jeecgboot / autopoi

AutoPOI 功能如同名字auto,追求的就是自动化,让一个没接触过poi的人员,可以傻瓜化的快速实现Excel导入导出、Word模板导出、可以仅仅5行代码就可以完成Excel的导入导出。
http://www.jeecg.com
Apache License 2.0
482 stars 205 forks source link

excel export junit #9

Open moonpure opened 4 years ago

moonpure commented 4 years ago

package org.jeecgframework.poi.excel.view;

import javax.servlet.http.HttpServletRequest; import org.springframework.web.servlet.view.AbstractView;

public abstract class MiniAbstractExcelView extends AbstractView { private static final String CONTENT_TYPE = "application/vnd.ms-excel"; protected static final String HSSF = ".xls"; protected static final String XSSF = ".xlsx";

public MiniAbstractExcelView() {
    this.setContentType("application/vnd.ms-excel");
}

protected boolean isIE(HttpServletRequest request) {
    return request.getHeader("USER-AGENT").toLowerCase().indexOf("msie") > 0 || request.getHeader("USER-AGENT").toLowerCase().indexOf("rv:11.0") > 0;
}

}

以上代码。当通过 mockmvc等进行测试时,如没有上传USER-AGENT会报错。为我这种小白增加困难,如能加入null 判断。则可解决

tygithub1 commented 4 years ago

好的