ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
**1. 实现拦截器SheetWriteHandler** ```java public class CustomSheetWriteHandler implements SheetWriteHandler { @Override public void afterSheetCreate(WriteWorkbookHolder writeWorkbookHolder, WriteSheetHolder writeSheetHolder) { Sheet sheet = writeSheetHolder.getSheet(); //冻结前1列,前1行 sheet.createFreezePane(1, 1); } } ``` **2. 注册拦截器** ```java @Test public void write01() { Integer num = 0; List<List<Integer>> dataList = Lists.newArrayList(); for (int row = 1; row <= 100; row++) { List<Integer> rowData = Lists.newArrayList(); for (int col = 1; col <= 50; col++) { rowData.add(num++); } dataList.add(rowData); } EasyExcel.write("e:/upload/easyexcel/003.xlsx") .sheet("Sheet1") //注册拦截器 .registerWriteHandler(new CustomSheetWriteHandler()) .doWrite(dataList); } ```