|
@@ -21,7 +21,7 @@ public class ExcelExportForMap { |
|
|
/**
|
|
|
/**
|
|
|
* Map 测试
|
|
|
* Map 测试
|
|
|
*/
|
|
|
*/
|
|
|
@Test
|
|
|
|
|
|
|
|
|
//@Test
|
|
|
public void test() {
|
|
|
public void test() {
|
|
|
try {
|
|
|
try {
|
|
|
List<ExcelExportEntity> entity = new ArrayList<ExcelExportEntity>();
|
|
|
List<ExcelExportEntity> entity = new ArrayList<ExcelExportEntity>();
|
|
@@ -62,6 +62,50 @@ public class ExcelExportForMap { |
|
|
e.printStackTrace();
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 合并同类项
|
|
|
|
|
|
*/
|
|
|
|
|
|
@Test
|
|
|
|
|
|
public void testMerge() {
|
|
|
|
|
|
try {
|
|
|
|
|
|
List<ExcelExportEntity> entity = new ArrayList<ExcelExportEntity>();
|
|
|
|
|
|
ExcelExportEntity excelentity = new ExcelExportEntity("部门", "depart");
|
|
|
|
|
|
excelentity.setMergeVertical(true);
|
|
|
|
|
|
excelentity.setMergeRely(new int[0]);
|
|
|
|
|
|
entity.add(excelentity);
|
|
|
|
|
|
|
|
|
|
|
|
entity.add(new ExcelExportEntity("姓名", "name"));
|
|
|
|
|
|
excelentity = new ExcelExportEntity("电话", "phone");
|
|
|
|
|
|
entity.add(excelentity);
|
|
|
|
|
|
|
|
|
|
|
|
List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
|
|
|
|
|
|
Map<String, Object> map;
|
|
|
|
|
|
for (int i = 0; i < 10; i++) {
|
|
|
|
|
|
map = new HashMap<String, Object>();
|
|
|
|
|
|
map.put("depart", "设计部");
|
|
|
|
|
|
map.put("name", "小明" + i);
|
|
|
|
|
|
map.put("phone", "1311234567" + i);
|
|
|
|
|
|
list.add(map);
|
|
|
|
|
|
}
|
|
|
|
|
|
for (int i = 0; i < 10; i++) {
|
|
|
|
|
|
map = new HashMap<String, Object>();
|
|
|
|
|
|
map.put("depart", "开发部");
|
|
|
|
|
|
map.put("name", "小蓝" + i);
|
|
|
|
|
|
map.put("phone", "1871234567" + i);
|
|
|
|
|
|
list.add(map);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams("员工通讯录", "通讯录"),
|
|
|
|
|
|
entity, list);
|
|
|
|
|
|
FileOutputStream fos = new FileOutputStream("d:/tt.xls");
|
|
|
|
|
|
workbook.write(fos);
|
|
|
|
|
|
fos.close();
|
|
|
|
|
|
} catch (FileNotFoundException e) {
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
//@Test
|
|
|
//@Test
|
|
|
public void testMany() {
|
|
|
public void testMany() {
|
|
|