ContentStyle.java 4.4 KB
Newer Older
庄家钜's avatar
庄家钜 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
package com.alibaba.excel.annotation.write.style;

import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

import org.apache.poi.ss.usermodel.BorderStyle;
import org.apache.poi.ss.usermodel.BuiltinFormats;
import org.apache.poi.ss.usermodel.FillPatternType;
import org.apache.poi.ss.usermodel.HorizontalAlignment;
import org.apache.poi.ss.usermodel.IgnoredErrorType;
import org.apache.poi.ss.usermodel.IndexedColors;
import org.apache.poi.ss.usermodel.VerticalAlignment;

/**
 * Custom content styles
 *
 * @author Jiaju Zhuang
 */
22
@Target({ElementType.FIELD, ElementType.TYPE})
庄家钜's avatar
庄家钜 已提交
23 24 25 26 27 28
@Retention(RetentionPolicy.RUNTIME)
@Inherited
public @interface ContentStyle {
    /**
     * Set the data format (must be a valid format). Built in formats are defined at {@link BuiltinFormats}.
     */
29
    short dataFormat() default -1;
庄家钜's avatar
庄家钜 已提交
30 31 32 33

    /**
     * Set the cell's using this style to be hidden
     */
34
    boolean hidden() default false;
庄家钜's avatar
庄家钜 已提交
35 36 37 38

    /**
     * Set the cell's using this style to be locked
     */
39
    boolean locked() default false;
庄家钜's avatar
庄家钜 已提交
40 41 42 43 44 45

    /**
     * Turn on or off "Quote Prefix" or "123 Prefix" for the style, which is used to tell Excel that the thing which
     * looks like a number or a formula shouldn't be treated as on. Turning this on is somewhat (but not completely, see
     * {@link IgnoredErrorType}) like prefixing the cell value with a ' in Excel
     */
46
    boolean quotePrefix() default false;
庄家钜's avatar
庄家钜 已提交
47 48 49 50

    /**
     * Set the type of horizontal alignment for the cell
     */
51
    HorizontalAlignment horizontalAlignment() default HorizontalAlignment.GENERAL;
庄家钜's avatar
庄家钜 已提交
52 53 54 55 56 57

    /**
     * Set whether the text should be wrapped. Setting this flag to <code>true</code> make all content visible within a
     * cell by displaying it on multiple lines
     *
     */
58
    boolean wrapped() default false;
庄家钜's avatar
庄家钜 已提交
59 60 61 62

    /**
     * Set the type of vertical alignment for the cell
     */
63
    VerticalAlignment verticalAlignment() default VerticalAlignment.CENTER;
庄家钜's avatar
庄家钜 已提交
64 65 66 67 68 69 70 71 72

    /**
     * Set the degree of rotation for the text in the cell.
     *
     * Note: HSSF uses values from -90 to 90 degrees, whereas XSSF uses values from 0 to 180 degrees. The
     * implementations of this method will map between these two value-ranges accordingly, however the corresponding
     * getter is returning values in the range mandated by the current type of Excel file-format that this CellStyle is
     * applied to.
     */
73
    short rotation() default -1;
庄家钜's avatar
庄家钜 已提交
74 75 76 77

    /**
     * Set the number of spaces to indent the text in the cell
     */
78
    short indent() default -1;
庄家钜's avatar
庄家钜 已提交
79 80 81 82

    /**
     * Set the type of border to use for the left border of the cell
     */
83
    BorderStyle borderLeft() default BorderStyle.NONE;
庄家钜's avatar
庄家钜 已提交
84 85 86 87

    /**
     * Set the type of border to use for the right border of the cell
     */
88
    BorderStyle borderRight() default BorderStyle.NONE;
庄家钜's avatar
庄家钜 已提交
89 90 91 92

    /**
     * Set the type of border to use for the top border of the cell
     */
93
    BorderStyle borderTop() default BorderStyle.NONE;
庄家钜's avatar
庄家钜 已提交
94 95 96 97

    /**
     * Set the type of border to use for the bottom border of the cell
     */
98
    BorderStyle borderBottom() default BorderStyle.NONE;
庄家钜's avatar
庄家钜 已提交
99 100 101 102 103 104

    /**
     * Set the color to use for the left border
     *
     * @see IndexedColors
     */
105
    short leftBorderColor() default -1;
庄家钜's avatar
庄家钜 已提交
106 107 108 109 110 111 112

    /**
     * Set the color to use for the right border
     *
     * @see IndexedColors
     *
     */
113
    short rightBorderColor() default -1;
庄家钜's avatar
庄家钜 已提交
114 115 116 117 118 119 120

    /**
     * Set the color to use for the top border
     *
     * @see IndexedColors
     *
     */
121
    short topBorderColor() default -1;
庄家钜's avatar
庄家钜 已提交
122 123 124 125 126 127 128

    /**
     * Set the color to use for the bottom border
     *
     * @see IndexedColors
     *
     */
129
    short bottomBorderColor() default -1;
庄家钜's avatar
庄家钜 已提交
130 131 132 133 134 135

    /**
     * Setting to one fills the cell with the foreground color... No idea about other values
     *
     * @see FillPatternType#SOLID_FOREGROUND
     */
136
    FillPatternType fillPatternType() default FillPatternType.NO_FILL;
庄家钜's avatar
庄家钜 已提交
137 138 139 140 141 142 143

    /**
     * Set the background fill color.
     *
     * @see IndexedColors
     *
     */
144
    short fillBackgroundColor() default -1;
庄家钜's avatar
庄家钜 已提交
145 146 147 148 149 150 151

    /**
     * Set the foreground fill color <i>Note: Ensure Foreground color is set prior to background color.</i>
     *
     * @see IndexedColors
     *
     */
152
    short fillForegroundColor() default -1;
庄家钜's avatar
庄家钜 已提交
153 154 155 156

    /**
     * Controls if the Cell should be auto-sized to shrink to fit if the text is too long
     */
157
    boolean shrinkToFit() default false;
庄家钜's avatar
庄家钜 已提交
158 159

}