easyexcel 导出到web 样例代码
时间: 2024-01-20 17:04:38 浏览: 83
Java导出excel工具详细介绍(POI 和 EasyExcel),各种复杂需求情况的导出(包括动态设置合并单元格等)
5星 · 资源好评率100%
Sure, here is a sample code for exporting data to web using EasyExcel:
```java
// create a workbook
ExcelWriter writer = EasyExcel.write("output.xlsx").build();
// create a sheet
Sheet sheet = new Sheet(1, 0);
// set the column name
List<String> head = new ArrayList<>();
head.add("Name");
head.add("Age");
sheet.setHead(head);
// set the data
List<List<Object>> data = new ArrayList<>();
List<Object> row1 = new ArrayList<>();
row1.add("Alice");
row1.add(25);
data.add(row1);
List<Object> row2 = new ArrayList<>();
row2.add("Bob");
row2.add(30);
data.add(row2);
// write the data to the sheet
writer.write1(data, sheet);
// close the workbook
writer.finish();
```
Hope it helps!
阅读全文