做poi导入导出:
导出功能还好比较简单,只需要指定好相应模板,对于日期格式的数据来说,同理模板需要设置日期,然后模板中大致的格式是
<jx:forEach items="${itsmciList}" var="itsmci"> | ||||
${itsmci.name} | ${itsmci.categoryvalue} | ${itsmci.version} | ${itsmci.sn} | ${itsmci.assetNumber} |
</jx:forEach> |
poi从数据库------到excel:原理是,先读模板,往模板注入数据,形成Workbook,workbooke经ServletOutputStream,流到浏览器端。
直接上代码:
导出
@RequestMapping("/itsmciExport.do")
public void itsmciExport(HttpServletRequest request,HttpServletResponse response) throws IOException, ParsePropertyException, InvalidFormatException
{
QueryParameter paramMap = new QueryParameter();
paramMap.addEquals("companyid", getUser().getCompanyId());
List<Itsm_ci> list = itsm_ciService.findListByParam(paramMap);
if(CollectionUtils.isNotEmpty(list)){
String companyId = list.get(0).getCompanyid();
Itsm_ci.formatList(companyId, list);//翻译
}
itsmCiFeatureproService.getFeatureproInfor(list); //加进特征信息
String fileName = getUser().getCompanyName()+"的配置项.xls";
Stri