EasyExce表头自适应列宽
// 自适应表头列宽策略
public class AdaptiveColumnWidthStrategy extends AbstractColumnWidthStyleStrategy {
@Override
protected void setColumnWidth(WriteSheetHolder writeSheetHolder, CellData cellData, Cell cell, Head head, int relativeRowIndex, boolean isHead) {
//表头自适应列宽
if (isHead) {
int length = cell.getStringCellValue().getBytes().length;
writeSheetHolder.getSheet().setColumnWidth(cell.getColumnIndex(), length * 300);
}
}
}