1.添加依赖
// Excel implementation 'org.apache.poi:poi:3.17' implementation 'org.apache.poi:poi-ooxml:3.17' implementation 'org.apache.xmlbeans:xmlbeans:3.1.0' implementation 'stax:stax:1.2.0' implementation 'com.alibaba:easyexcel:2.2.10'
2.实现一个简单的java.awt.Color类
package java.awt;
public class Color {
public static final Color white;
public static final Color WHITE;
public static final Color lightGray;
public static final Color LIGHT_GRAY;
public static final Color gray;
public static final Color GRAY;
public static final Color darkGray;
public static final Color DARK_GRAY;
public static final Color black;
public static final Color BLACK;
public static final Color red;
public static final Color RED;
public static final Color pink;
public static final Color PINK;
public static final Color orange;
public static final Color ORANGE;
public static final Color yellow;
public static final Color YELLOW;
public static final Color green;
public static final Color GREEN;
public static final Color magenta;
public static final Color MAGENTA;
public static final Color cyan;
public static final Color CYAN;
public static final Color blue;
public static final Color BLUE;
int value;
public Color(int red, int green, int blue) {
this(red, green, blue, 255);
}
public Color(int red, int green, int blue, int alpha) {
this.value = (alpha & 255) << 24 | (red & 255) << 16 | (green & 255) << 8 | (blue & 255);
}
public Color(int rgb) {
this.value = -16777216 | rgb;
}
public int getRed() {
return this.getRGB() >> 16 & 255;
}
public int getGreen() {
return this.getRGB() >> 8 & 255;
}
public int getBlue() {
return this.getRGB() & 255;
}
public int getAlpha() {
return this.getRGB() >> 24 & 255;
}
public int getRGB() {
return this.value;
}
static {
white = new Color(255, 255, 255);
WHITE = white;
lightGray = new Color(192, 192, 192);
LIGHT_GRAY = lightGray;
gray = new Color(128, 128, 128);
GRAY = gray;
darkGray = new Color(64, 64, 64);
DARK_GRAY = darkGray;
black = new Color(0, 0, 0);
BLACK = black;
red = new Color(255, 0, 0);
RED = red;
pink = new Color(255, 175, 175);
PINK = pink;
orange = new Color(255, 200, 0);
ORANGE = orange;
yellow = new Color(255, 255, 0);
YELLOW = yellow;
green = new Color(0, 255, 0);
GREEN = green;
magenta = new Color(255, 0, 255);
MAGENTA = magenta;
cyan = new Color(0, 255, 255);
CYAN = cyan;
blue = new Color(0, 0, 255);
BLUE = blue;
}
}
3.使用Map和List<Map>填充普通数据和列表数据
参考链接: