项目有一个导出excel的功能使用的是2003版的,那2003版的excel单个sheet最多只能导出65535条数据,现在项目有一个导出的功能数据会超过65535条。所以需要导出到多个sheet里面,类似分页处理。
代码如下
public static void main(String[] args) throws Exception{
String filePath = "d:/template.xls";
System.out.println("excel template file:" + filePath);
FileInputStream is = new FileInputStream(filePath);
//创建测试数据
Map<String, Object> map = new HashMap<String, Object>();
List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
Map<String, Object> map1 = new HashMap<String, Object>();
map1.put("name", "name");
map1.put("price", "price");
map1.put("desc", "desc");
map1.put("remark", "remark");
Map<String, Object> map2 = new HashMap<String, Object>();
map2.put("name", "name2");
map2.put("price", "price2");
map2.put("desc", "desc2"