EasyExcel表格导出自动列宽设定

EasyExcel表格导出自动列宽设定

 public static class AutoColumnWidthStrategy implements CellWriteHandler {

        @Override
        public void beforeCellCreate(WriteSheetHolder writeSheetHolder, WriteTableHolder writeTableHolder, Row row, Head head, Integer integer, Integer integer1, Boolean isHead) {

        }

        @Override
        public void afterCellCreate(WriteSheetHolder writeSheetHolder, WriteTableHolder writeTableHolder, Cell cell, Head head, Integer relativeRowIndex, Boolean isHead) {

        }

        @Override
        public void afterCellDataConverted(WriteSheetHolder writeSheetHolder, WriteTableHolder writeTableHolder, CellData cellData, Cell cell, Head head, Integer relativeRowIndex, Boolean isHead) {

        }

        @Override
        public void afterCellDispose(WriteSheetHolder writeSheetHolder, WriteTableHolder writeTableHolder, List<CellData> list, Cell cell, Head head, Integer relativeRowIndex, Boolean isHead) {
            SXSSFSheet sheet = (SXSSFSheet)writeSheetHolder.getSheet();
            sheet.trackAllColumnsForAutoSizing();
            sheet.autoSizeColumn(cell.getColumnIndex());
        }
    }

你可能感兴趣的:(POI,excel,poi)