使用postman测试下载xls文件,下载的文件名出现中文乱码
使用postman测试下载xls文件,下载的文件名出现中文乱码public void exportTeam(AdminInfo adminInfo, SelectTeamDTO dto, HttpServletRequest request, HttpServletResponse response) {
//导出时取消分页
dto.setPageSize(Integer.MAX_VALUE);
dto.setPageIndex(1);
//查询数据
BasePageResponse<SelectTeamVO> teamList = teamManageService.selectTeamPage(adminInfo, dto.getTeamName(), dto.getPageIndex(), dto.getPageSize());
List<SelectTeamVO> records = teamList.getRecords();
List<SelectTeamVO> vos = new ArrayList<>();
//设置属性
records.forEach(p -> {
SelectTeamVO vo = new SelectTeamVO();
BeanUtils.copyProperties(p, vo);
vos.add(vo);
});
String sheetName = ExportSheetNameEnum.team_sheet;
String fileName = sheetName + ".xls";
String[] title = ExportTitleEnum.teamList_title;
String[][] values = new String;
for (int i = 0; i < vos.size(); i++) {
values = new String;
SelectTeamVO vo = vos.get(i);
values = vo.getTeamName();
values = vo.getTeamType();
values = vo.getProjectName();
values = vo.getLeaderName();
values = vo.getTeamTypeNo();
}
//初始化表格设置
Map<String, Object> map = ExcelUtil.exportFirstSet(sheetName, title);
HSSFRow row = (HSSFRow) map.get("HSSFRow");
HSSFSheet sheet = (HSSFSheet) map.get("HSSFSheet");
HSSFWorkbook wb = (HSSFWorkbook) map.get("HSSFWorkbook");
//创建内容
for (int i = 0; i < values.length; i++) {
row = sheet.createRow(i + 1);
for (int j = 0; j < values.length; j++) {
row.createCell(j).setCellValue(values);
}
}
//设置样式
ExcelUtil.setHeightWidth(values, null, null, row, sheet);
//响应到客户端
try {
ExcelUtil.setResponseHeader(response, request, fileName);
OutputStream os = response.getOutputStream();
wb.write(os);
os.flush();
os.close();
} catch (Exception e) {
e.printStackTrace();
}
}
编码格式的问题 一般是编码格式问题 UFT-8
页:
[1]