/**
* 导出项目
*/
@GetMapping(value = "/list/{name}/{txt}", consumes = "application/json")
public BaseResponse download(@PathVariable String name, @PathVariable String txt) {
Page page = new PageContext(1L, 10L);
List list = managerService.getEnterpriseByNameExport(page, txt, name);
/*List keyComplete = new ArrayList();
keyComplete.add("QYMC");
keyComplete.add("mainId");
keyComplete.add("FDDBR");
keyComplete.add("ZCZB");
keyComplete.add("BZ");
keyComplete.add("QYBQ");
for (int i = 0; i < list.size(); i++) {
Map map = (Map) list.get(i);
if (map.size() < 6) {
List listKey = new ArrayList();
Iterator it = map.keySet().iterator();
while (it.hasNext()) {
String key = it.next().toString();
listKey.add(key);
}
Collection exists = new ArrayList(keyComplete);
list.remove(i);
list.add(map.put(exists.removeAll(listKey), "-"));
}
}*/
exportAccountData(list);
return BaseResponse.success();
}
private void exportAccountData(List list) {
try {
HSSFWorkbook book = new HSSFWorkbook();
HSSFSheet sheet = book.createSheet();
Row rowFirst = sheet.createRow(0);
Cell cell1 = rowFirst.createCell(0);
cell1.setCellValue("企业名称");
Cell cell2 = rowFirst.createCell(1);
cell2.setCellValue("统一社会信用代码");
Cell cell3 = rowFirst.createCell(2);
cell3.setCellValue("法定代表人");
Cell cell4 = rowFirst.createCell(3);
cell4.setCellValue("注册资本");
Cell cell5 = rowFirst.createCell(4);
cell5.setCellValue("币种");
Cell cell6 = rowFirst.createCell(5);
cell6.setCellValue("企业标签 ");
for (int i = 1; i < list.size(); i++) {
Row row = sheet.createRow(i);
for (int j = 65; j < 71; j++) {
Cell cell = row.createCell(j - 65);
Map map = (Map) list.get(i);
cell.setCellValue((String) map.get(String.valueOf((char) j)));
}
/*Map map = (Map) list.get(i);
List listKey = new ArrayList();
List listValue = new ArrayList();
Iterator it = map.keySet().iterator();
while (it.hasNext()) {
String key = it.next().toString();
listKey.add(key);
if (map.get(key).equals("") || map.get(key) == null) {
listValue.add("-");
} else {
listValue.add(map.get(key));
}
}
Set<Map.Entry<String, String>> entrySet = map.entrySet();
for (int j = 0; j < listKey.size(); j++) {
*//* System.out.print("Key :" + listKey.get(i));
System.out.println(" Value :" +listValue.get(i) );*//*
Cell cell1 = row.createCell(j);
cell1.setCellValue(listValue.get(j).toString());
}
*/
/*for (int j = 0; j < entrySet.size(); j++) {
Cell cell1 = row.createCell(j);
cell1.setCellValue(1);
}*/
/*for (Map.Entry<String, String> entry : entrySet) {
entry.getKey();
cell1.setCellValue(entry.getValue());
}*/
}
FileOutputStream fos = new FileOutputStream(new File("D:\\crms\\新建 XLS 工作表.xls"));
book.write(fos);
book.close();
fos.close();
} catch (Exception e) {
e.printStackTrace();
}
}