com.alibaba.excel.annotation.write.style.HeadRowHeight Java Examples

The following examples show how to use com.alibaba.excel.annotation.write.style.HeadRowHeight. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RowHeightProperty.java    From easyexcel with Apache License 2.0 4 votes vote down vote up
public static RowHeightProperty build(HeadRowHeight headRowHeight) {
    if (headRowHeight == null || headRowHeight.value() < 0) {
        return null;
    }
    return new RowHeightProperty(headRowHeight.value());
}
 
Example #2
Source File: ExcelWriteHeadProperty.java    From easyexcel with Apache License 2.0 4 votes vote down vote up
public ExcelWriteHeadProperty(Holder holder, Class headClazz, List<List<String>> head, Boolean convertAllFiled) {
    super(holder, headClazz, head, convertAllFiled);
    if (getHeadKind() != HeadKindEnum.CLASS) {
        return;
    }
    this.headRowHeightProperty =
        RowHeightProperty.build((HeadRowHeight) headClazz.getAnnotation(HeadRowHeight.class));
    this.contentRowHeightProperty =
        RowHeightProperty.build((ContentRowHeight) headClazz.getAnnotation(ContentRowHeight.class));
    this.onceAbsoluteMergeProperty =
        OnceAbsoluteMergeProperty.build((OnceAbsoluteMerge) headClazz.getAnnotation(OnceAbsoluteMerge.class));

    ColumnWidth parentColumnWidth = (ColumnWidth) headClazz.getAnnotation(ColumnWidth.class);
    HeadStyle parentHeadStyle = (HeadStyle) headClazz.getAnnotation(HeadStyle.class);
    HeadFontStyle parentHeadFontStyle = (HeadFontStyle) headClazz.getAnnotation(HeadFontStyle.class);
    ContentStyle parentContentStyle = (ContentStyle) headClazz.getAnnotation(ContentStyle.class);
    ContentFontStyle parentContentFontStyle = (ContentFontStyle) headClazz.getAnnotation(ContentFontStyle.class);

    for (Map.Entry<Integer, ExcelContentProperty> entry : getContentPropertyMap().entrySet()) {
        Integer index = entry.getKey();
        ExcelContentProperty excelContentPropertyData = entry.getValue();
        if (excelContentPropertyData == null) {
            throw new IllegalArgumentException(
                "Passing in the class and list the head, the two must be the same size.");
        }
        Field field = excelContentPropertyData.getField();
        Head headData = getHeadMap().get(index);
        ColumnWidth columnWidth = field.getAnnotation(ColumnWidth.class);
        if (columnWidth == null) {
            columnWidth = parentColumnWidth;
        }
        headData.setColumnWidthProperty(ColumnWidthProperty.build(columnWidth));

        HeadStyle headStyle = field.getAnnotation(HeadStyle.class);
        if (headStyle == null) {
            headStyle = parentHeadStyle;
        }
        headData.setHeadStyleProperty(StyleProperty.build(headStyle));

        HeadFontStyle headFontStyle = field.getAnnotation(HeadFontStyle.class);
        if (headFontStyle == null) {
            headFontStyle = parentHeadFontStyle;
        }
        headData.setHeadFontProperty(FontProperty.build(headFontStyle));

        ContentStyle contentStyle = field.getAnnotation(ContentStyle.class);
        if (contentStyle == null) {
            contentStyle = parentContentStyle;
        }
        headData.setContentStyleProperty(StyleProperty.build(contentStyle));

        ContentFontStyle contentFontStyle = field.getAnnotation(ContentFontStyle.class);
        if (contentFontStyle == null) {
            contentFontStyle = parentContentFontStyle;
        }
        headData.setContentFontProperty(FontProperty.build(contentFontStyle));

        headData.setLoopMergeProperty(LoopMergeProperty.build(field.getAnnotation(ContentLoopMerge.class)));
        // If have @NumberFormat, 'NumberStringConverter' is specified by default
        if (excelContentPropertyData.getConverter() == null) {
            NumberFormat numberFormat = field.getAnnotation(NumberFormat.class);
            if (numberFormat != null) {
                excelContentPropertyData.setConverter(DefaultConverterLoader.loadAllConverter()
                    .get(ConverterKeyBuild.buildKey(field.getType(), CellDataTypeEnum.STRING)));
            }
        }
    }
}