解决POIExcelWriter导出excel表乱码问题

number__ 2016-09-07 10:49:41
public String cbxxycHxList() {
String retUrl = request.getHeader("Referer");
AbstractUser user = loginedUser().getUser();
if (!(user instanceof UserInfo)) {
throw new DataException("您不是组织内用户");
}
DepartmentQuery departmentQuery = departmentService.createQuery();
departmentQuery.subs(IaolnContants.ORG_LIAONING,2);
departmentQuery.type(DepartmentType.BusinessUnit);
List<Department> departmentList = departmentQuery.list();

List<Catalog> xzleixing = catalogService .listSubsForQuery(IaolnContants.CBXZ_TYPE);
CatalogQuery catalogQuery = catalogService.createQuery();
catalogQuery.idLayerLike(IaolnContants.AREA_TYPE);
catalogQuery.status(0);
catalogQuery.depthLessThan(3);
catalogQuery.depthGreateThan(1);
catalogQuery.orderByOrderNo();
List<Catalog> areas = catalogQuery.list();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
String name = request.getParameter("username");
String idCard = request.getParameter("idCard");
String startTime = request.getParameter("startTime");
String endTime = request.getParameter("endTime");
String[] dqmc = request.getParameterValues("dqmc");
String[] xzlx = request.getParameterValues("xzleixing");
CbxxQuery query = cbxxService.createQuery();
if (name != null && !"".equals(name)) {
query.bbxrName(name);
}
if (idCard != null && !"".equals(idCard)) {
query.idCard(idCard);
}
if (startTime != null && !"".equals(startTime)) {
try {
query.chengbaoTime(sdf.parse(startTime));
} catch (ParseException e) {
e.printStackTrace();
}
}
if (endTime != null && !"".equals(endTime)) {
try {
query.chengbaoendTime(sdf.parse(endTime));
} catch (ParseException e) {
e.printStackTrace();
}
}
if (dqmc != null && !"".equals(dqmc)) {
query.dqmcs(dqmc);
}
if (xzlx != null && !"".equals(xzlx)) {
query.xzlxs(xzlx);
}
if (insuranceId != null && !"".equals(insuranceId)) {
String[] insuranceIds = insuranceId.split(",");
query.companyIds(insuranceIds);
}
query.orderByCreateTime(Direction.DESC);
String order = getParameter("_order");
final Map<String, String[]> parameterMap = new HashMap<String, String[]>();
parameterMap.putAll(request.getParameterMap());
if (StringUtils.isEmpty(order)) {
parameterMap.put("_order", new String[] { "orderByID" });
parameterMap.put("_orderparam", new String[] { "desc" });
}
query.orderByCreateTime(Direction.DESC);
PagedList<Cbxx> list = query.listRange(getOffset(), getLimit());
List<Cbxx> listAll = query.list();
String downLoad = request.getParameter("downLoadhxForm");
if (downLoad != null && downLoad.equals("hxForm")) {
POIExcelWriter writer = new POIExcelWriter(PoiExcelType.XLSX);
writer.addSheet("承保异常数据");
CellStyle titleCellStyle = writer.createCellStyle("string");
Font titleFont = writer.createFont();
titleFont.setFontHeightInPoints((short) 18);
titleFont.setBoldweight(Font.BOLDWEIGHT_BOLD);
titleFont.setFontName("宋体");
titleCellStyle.setFont(titleFont);
titleCellStyle.setAlignment(CellStyle.ALIGN_CENTER);
writer.merge(0, "A", 0, "E");
writer.setData(1, "A", "承保异常信息表");
writer.clearStyles();

CellStyle titleCellStyle0 = writer.createCellStyle("string");
Font titleFont0 = writer.createFont();
titleFont0.setFontHeightInPoints((short) 10);
titleFont0.setFontName("宋体");
titleCellStyle0.setFont(titleFont0);
titleCellStyle0.setAlignment(CellStyle.ALIGN_RIGHT);
writer.merge(1, "A", 1, "E");
writer.setData(2, "A", "单位:元");
writer.clearStyles();

CellStyle titleCellStyle1 = writer.createCellStyle("string");
Font titleFont1 = writer.createFont();
titleFont1.setFontHeightInPoints((short) 11);
titleFont1.setBoldweight(Font.BOLDWEIGHT_BOLD);
titleFont1.setFontName("宋体");
titleCellStyle1.setFont(titleFont1);
titleCellStyle1.setAlignment(CellStyle.ALIGN_CENTER);
titleCellStyle1.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
titleCellStyle1.setBorderTop(CellStyle.BORDER_THIN);
titleCellStyle1.setBorderBottom(CellStyle.BORDER_THIN);
titleCellStyle1.setBorderLeft(CellStyle.BORDER_THIN);
titleCellStyle1.setBorderRight(CellStyle.BORDER_THIN);

writer.setColumnWidth("A", 5000);
writer.setColumnWidth("B", 5000);
writer.setColumnWidth("C", 5000);
writer.setColumnWidth("D", 5000);
writer.setColumnWidth("E", 5000);

writer.setData(3, "A", "客户姓名");
writer.setData(3, "B", "身份证号");
writer.setData(3, "C", "公司");
writer.setData(3, "D", "险种类型");
writer.setData(3, "E", "承保时间");
writer.clearStyles();
if(StringUtils.indexOf(retUrl, "cbxxycHx.action") > -1){
}else if(StringUtils.indexOf(retUrl, "cbxxycHxList.action") > -1){
if (listAll != null && !listAll.isEmpty()) {
for (int i = 0; i < listAll.size(); i++) {
writer.setData(i + 4, "A", listAll.get(i).getBbxrName());
writer.setData(i + 4, "B", listAll.get(i).getIdCard());
writer.setData(i + 4, "C", listAll.get(i).getCompanyName());
writer.setData(i + 4, "D", listAll.get(i).getXzLeixing());
writer.setData(i + 4, "E", listAll.get(i).getChengbaoTime(), "yyyy-MM-DD");
}
}
}
try {
response.setContentType("applicationnd.ms-excel");
String fileName = "承保异常数据.xlsx";
String browserName = BrowserUtils.getBrowserName(request);
if (StringUtils.indexOf(browserName, "ie") > -1
|| StringUtils.indexOf(browserName, "edge") > -1
|| StringUtils.indexOf(browserName, "webkit") > -1) {
fileName = java.net.URLEncoder.encode(fileName, "UTF8");
} else {
fileName = new String(fileName.getBytes("UTF-8"), "ISO-8859-1");
}
response.setContentType("applicationnd.ms-excel");
response.setHeader("Content-disposition", "attachment;filename="
+ fileName);
OutputStream os = response.getOutputStream();
writer.writeTo(os);
os.close();
} catch (Exception e) {
}
return null;
}
request.setAttribute("list", list);
request.setAttribute("areas", areas);
request.setAttribute("menuId", "cbproblemdata_cbxxycHx");
request.setAttribute("xzleixing", xzleixing);
request.setAttribute("departmentList", departmentList);
return "yclistHx";
}
...全文
784 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复
内容概要:本文系统阐述了基于矩约束的最大熵方法在扩展不确定度评估中的理论与应用,提供了一套完整的Matlab代码实现方案。该方法依据最大熵原理,在仅知样本的均值、方差、偏度、峰度等低阶矩信息的前提下,通过求解拉格朗日乘子,推导出满足这些矩约束且信息熵最大的最优概率密度函数,从而实现对测量结果的非参数化、无偏估计。相较于传统依赖正态分布假设的评估方式,该方法更具普适性与鲁棒性,尤其适用于处理非对称、非高斯等复杂分布的实际测量数据。文中详细论述了理论模型的构建、数值求解算法的设计、概率密度函数的重建过程,并通过典型算例验证了其在提高评估准确性方面的优越性能。; 适合人群:具备概率统计、信息论基础知识及Matlab编程能力,从事精密测量、实验数据分析、质量控制、计量科学等相关领域的研究人员、工程师及研究生。; 使用场景及目标:①解决传统扩展不确定度评估中因错误分布假设导致的系统性偏差问题;②在缺乏先验分布知识的情况下,对复杂测量数据进行客观、稳健的不确定度评定;③为高精度科学实验、工业检测及计量认证提供理论严谨、工具完备的技术支撑。; 阅读建议:建议读者结合提供的Matlab代码深入理解算法实现,重点关注拉格朗日乘子的迭代求解、熵最大化过程及PDF重构等核心环节,并尝试代入实际数据进行验证与拓展,以充分掌握该方法的应用精髓。
内容概要:本文研究了基于鲸鱼优化算法(WOA)的多无人机三维协同路径规划方法,旨在实现最低成本目标,综合考虑路径长度、飞行高度、环境威胁和转弯角度等多种约束条件。通过构建多目标优化模型,并利用WOA算法进行求解,实现了多无人机在复杂三维空间中的集群避障与路径优化。文中详细阐述了问题建模过程、适应度函数设计、约束处理机制以及算法实现细节,并借助Matlab仿真验证了该方法在路径平滑性、避障能力和成本控制方面的有效性,为多无人机系统的自主协同作业提供了可靠的技术支撑与实践方案。; 适合人群:具备一定优化算法基础和Matlab编程能力,从事无人机控制、智能优化、路径规划等相关领域的科研人员及高校研究生。; 使用场景及目标:①解决复杂三维环境中多无人机协同避障与高效路径规划问题;②学习如何将鲸鱼优化算法应用于多目标工程优化任务;③掌握基于Matlab的智能算法仿真、性能评估与可视化分析方法; 阅读建议:建议读者结合提供的Matlab代码深入理解算法实现过程,重点关注目标函数的构建逻辑与多约束条件的处理策略,可通过调整环境参数、初始条件和算法参数开展对比实验,以全面掌握多无人机协同路径规划的核心机制与优化技巧。

62,621

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧