Skip to content

Commit 9991b50

Browse files
committed
增加方法,突破cellStyle绑定wk约束
1 parent 77c5e39 commit 9991b50

3 files changed

Lines changed: 218 additions & 0 deletions

File tree

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
package seven.callBack;
2+
//=======================================================
3+
// .----.
4+
// _.'__ `.
5+
// .--(^)(^^)---/!\
6+
// .' @ /!!!\
7+
// : , !!!!
8+
// `-..__.-' _.-\!!!/
9+
// `;_: `"'
10+
// .'"""""`.
11+
// /, ya ,\\
12+
// //狗神保佑\\
13+
// `-._______.-'
14+
// ___`. | .'___
15+
// (______|______)
16+
//=======================================================
17+
18+
import org.apache.poi.ss.usermodel.Workbook;
19+
import seven.savewapper.cellStyle.CellStyle;
20+
21+
import java.util.Map;
22+
23+
/**
24+
* [Zhihu]https://www.zhihu.com/people/Sweets07
25+
* [Github]https://github.com/MatrixSeven
26+
* Created by seven on 2017/1/11.
27+
*/
28+
public class CellStyleCallbackInterface {
29+
CellStyleInterface cellStyle;
30+
String name;
31+
32+
public CellStyleCallbackInterface( String name,CellStyleInterface cellStyle) {
33+
this.cellStyle = cellStyle;
34+
this.name = name;
35+
}
36+
37+
public void create(Workbook wk, Map<String, CellStyle> cellStyleMap) throws Exception {
38+
cellStyleMap.put(name, cellStyle.create(CellStyle.CreateStyle(wk.createCellStyle())));
39+
}
40+
41+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package seven.callBack;
2+
//=======================================================
3+
// .----.
4+
// _.'__ `.
5+
// .--(^)(^^)---/!\
6+
// .' @ /!!!\
7+
// : , !!!!
8+
// `-..__.-' _.-\!!!/
9+
// `;_: `"'
10+
// .'"""""`.
11+
// /, ya ,\\
12+
// //狗神保佑\\
13+
// `-._______.-'
14+
// ___`. | .'___
15+
// (______|______)
16+
//=======================================================
17+
18+
import seven.savewapper.cellStyle.CellStyle;
19+
20+
/**
21+
* [Zhihu]https://www.zhihu.com/people/Sweets07
22+
* [Github]https://github.com/MatrixSeven
23+
* Created by seven on 2017/1/11.
24+
*/
25+
@FunctionalInterface
26+
public interface CellStyleInterface {
27+
CellStyle create(CellStyle cellStyle);
28+
}
Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
package seven.savewapper.cellStyle;
2+
//=======================================================
3+
// .----.
4+
// _.'__ `.
5+
// .--(^)(^^)---/!\
6+
// .' @ /!!!\
7+
// : , !!!!
8+
// `-..__.-' _.-\!!!/
9+
// `;_: `"'
10+
// .'"""""`.
11+
// /, ya ,\\
12+
// //狗神保佑\\
13+
// `-._______.-'
14+
// ___`. | .'___
15+
// (______|______)
16+
//=======================================================
17+
18+
import org.apache.poi.ss.usermodel.*;
19+
20+
/**
21+
* [Zhihu]https://www.zhihu.com/people/Sweets07
22+
* [Github]https://github.com/MatrixSeven
23+
* Created by seven on 2017/1/11.
24+
*/
25+
public class CellStyle {
26+
27+
private CellStyle(org.apache.poi.ss.usermodel.CellStyle cellStyle) {
28+
this.cellStyle = cellStyle;
29+
}
30+
31+
public CellStyle setDataFormat(short fmt) {
32+
cellStyle.setDataFormat(fmt);
33+
return this;
34+
}
35+
36+
public CellStyle setFont(Font font) {
37+
cellStyle.setFont(font);
38+
return this;
39+
}
40+
41+
public CellStyle setHidden(boolean hidden) {
42+
cellStyle.setHidden(hidden);
43+
return this;
44+
}
45+
46+
public CellStyle setLocked(boolean locked) {
47+
cellStyle.setLocked(locked);
48+
return this;
49+
}
50+
51+
public CellStyle setAlignment(HorizontalAlignment align) {
52+
cellStyle.setAlignment(align);
53+
return this;
54+
}
55+
56+
public CellStyle setWrapText(boolean wrapped) {
57+
cellStyle.setWrapText(wrapped);
58+
return this;
59+
}
60+
61+
public CellStyle setVerticalAlignment(VerticalAlignment align) {
62+
cellStyle.setVerticalAlignment(align);
63+
return this;
64+
}
65+
66+
public CellStyle setRotation(short rotation) {
67+
cellStyle.setRotation(rotation);
68+
return this;
69+
}
70+
71+
public CellStyle setIndention(short indent) {
72+
cellStyle.setIndention(indent);
73+
return this;
74+
}
75+
76+
public CellStyle setBorderLeft(BorderStyle border) {
77+
cellStyle.setBorderLeft(border);
78+
return this;
79+
}
80+
81+
public CellStyle setBorderRight(BorderStyle border) {
82+
cellStyle.setBorderRight(border);
83+
return this;
84+
}
85+
86+
public CellStyle setBorderTop(BorderStyle border) {
87+
cellStyle.setBorderTop(border);
88+
return this;
89+
}
90+
91+
public CellStyle setBorderBottom(BorderStyle border) {
92+
cellStyle.setBorderBottom(border);
93+
return this;
94+
}
95+
96+
public CellStyle setLeftBorderColor(short color) {
97+
cellStyle.setLeftBorderColor(color);
98+
return this;
99+
}
100+
101+
public CellStyle setRightBorderColor(short color) {
102+
cellStyle.setRightBorderColor(color);
103+
return this;
104+
}
105+
106+
public CellStyle setTopBorderColor(short color) {
107+
cellStyle.setTopBorderColor(color);
108+
return this;
109+
}
110+
111+
public CellStyle setBottomBorderColor(short color) {
112+
cellStyle.setBottomBorderColor(color);
113+
return this;
114+
}
115+
116+
public CellStyle setFillPattern(FillPatternType fp) {
117+
cellStyle.setFillPattern(fp);
118+
return this;
119+
}
120+
121+
public CellStyle setFillBackgroundColor(short bg) {
122+
cellStyle.setFillBackgroundColor(bg);
123+
return this;
124+
}
125+
126+
public CellStyle setFillForegroundColor(short bg) {
127+
cellStyle.setFillForegroundColor(bg);
128+
return this;
129+
}
130+
131+
public CellStyle cloneStyleFrom(org.apache.poi.ss.usermodel.CellStyle source) {
132+
cellStyle.cloneStyleFrom(source);
133+
return this;
134+
}
135+
136+
public CellStyle setShrinkToFit(boolean shrinkToFit) {
137+
cellStyle.setShrinkToFit(shrinkToFit);
138+
return this;
139+
}
140+
141+
public org.apache.poi.ss.usermodel.CellStyle getRealyStyle() {
142+
return this.cellStyle;
143+
}
144+
145+
private org.apache.poi.ss.usermodel.CellStyle cellStyle;
146+
public static final CellStyle CreateStyle(org.apache.poi.ss.usermodel.CellStyle cellStyle ) {
147+
return new CellStyle(cellStyle).setFillPattern(FillPatternType.BRICKS);
148+
}
149+
}

0 commit comments

Comments
 (0)