package jnpf.handler;

import com.alibaba.excel.write.handler.RowWriteHandler;
import com.alibaba.excel.write.metadata.holder.WriteSheetHolder;
import com.alibaba.excel.write.metadata.holder.WriteTableHolder;
import org.apache.poi.ss.usermodel.Row;

public class CustomRowHeightHandler implements RowWriteHandler {

    // 表头行高（单位：点）
    private static final float HEAD_ROW_HEIGHT = 20f;
    // 内容行高（单位：点）
    private static final float CONTENT_ROW_HEIGHT = 17f;

    @Override
    public void afterRowCreate(WriteSheetHolder writeSheetHolder, WriteTableHolder writeTableHolder, Row row, Integer relativeRowIndex, Boolean isHead) {
        if (isHead) {
            // 设置表头行高
            row.setHeightInPoints(HEAD_ROW_HEIGHT);
        } else {
            // 设置内容行高
            row.setHeightInPoints(CONTENT_ROW_HEIGHT);
        }
    }
}