embulk-parser-poi_excel 0.1.4 → 0.1.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +52 -5
- data/build.gradle +17 -11
- data/gradle/wrapper/gradle-wrapper.jar +0 -0
- data/gradle/wrapper/gradle-wrapper.properties +5 -6
- data/gradlew +43 -35
- data/gradlew.bat +4 -10
- data/src/main/java/org/embulk/parser/poi_excel/PoiExcelColumnValueType.java +4 -0
- data/src/main/java/org/embulk/parser/poi_excel/PoiExcelParserPlugin.java +80 -3
- data/src/main/java/org/embulk/parser/poi_excel/bean/PoiExcelColumnBean.java +110 -6
- data/src/main/java/org/embulk/parser/poi_excel/bean/PoiExcelColumnIndex.java +74 -37
- data/src/main/java/org/embulk/parser/poi_excel/bean/util/PoiExcelCellAddress.java +50 -0
- data/src/main/java/org/embulk/parser/poi_excel/bean/util/SearchMergedCell.java +71 -0
- data/src/main/java/org/embulk/parser/poi_excel/visitor/PoiExcelCellFontVisitor.java +0 -6
- data/src/main/java/org/embulk/parser/poi_excel/visitor/PoiExcelCellStyleVisitor.java +11 -11
- data/src/main/java/org/embulk/parser/poi_excel/visitor/PoiExcelCellTypeVisitor.java +52 -0
- data/src/main/java/org/embulk/parser/poi_excel/visitor/PoiExcelCellValueVisitor.java +79 -40
- data/src/main/java/org/embulk/parser/poi_excel/visitor/PoiExcelClientAnchorVisitor.java +1 -1
- data/src/main/java/org/embulk/parser/poi_excel/visitor/PoiExcelColumnVisitor.java +64 -4
- data/src/main/java/org/embulk/parser/poi_excel/visitor/PoiExcelVisitorFactory.java +14 -0
- data/src/main/java/org/embulk/parser/poi_excel/visitor/embulk/BooleanCellVisitor.java +5 -0
- data/src/main/java/org/embulk/parser/poi_excel/visitor/embulk/CellVisitor.java +3 -0
- data/src/main/java/org/embulk/parser/poi_excel/visitor/embulk/DoubleCellVisitor.java +5 -0
- data/src/main/java/org/embulk/parser/poi_excel/visitor/embulk/LongCellVisitor.java +5 -0
- data/src/main/java/org/embulk/parser/poi_excel/visitor/embulk/StringCellVisitor.java +30 -2
- data/src/main/java/org/embulk/parser/poi_excel/visitor/embulk/TimestampCellVisitor.java +5 -0
- data/src/main/java/org/embulk/parser/poi_excel/visitor/util/MergedRegionFinder.java +9 -0
- data/src/main/java/org/embulk/parser/poi_excel/visitor/util/MergedRegionList.java +20 -0
- data/src/main/java/org/embulk/parser/poi_excel/visitor/util/MergedRegionMap.java +55 -0
- data/src/main/java/org/embulk/parser/poi_excel/visitor/util/MergedRegionNothing.java +12 -0
- data/src/test/java/org/embulk/parser/poi_excel/TestPoiExcelParserPlugin.java +27 -79
- data/src/test/java/org/embulk/parser/poi_excel/TestPoiExcelParserPlugin_cellAddress.java +69 -0
- data/src/test/java/org/embulk/parser/poi_excel/TestPoiExcelParserPlugin_cellComment.java +1 -1
- data/src/test/java/org/embulk/parser/poi_excel/TestPoiExcelParserPlugin_cellError.java +1 -1
- data/src/test/java/org/embulk/parser/poi_excel/TestPoiExcelParserPlugin_cellFont.java +1 -1
- data/src/test/java/org/embulk/parser/poi_excel/TestPoiExcelParserPlugin_cellStyle.java +14 -14
- data/src/test/java/org/embulk/parser/poi_excel/TestPoiExcelParserPlugin_cellType.java +79 -0
- data/src/test/java/org/embulk/parser/poi_excel/TestPoiExcelParserPlugin_columnNumber.java +1 -1
- data/src/test/java/org/embulk/parser/poi_excel/TestPoiExcelParserPlugin_constant.java +1 -1
- data/src/test/java/org/embulk/parser/poi_excel/TestPoiExcelParserPlugin_convertError.java +1 -1
- data/src/test/java/org/embulk/parser/poi_excel/TestPoiExcelParserPlugin_formula.java +90 -0
- data/src/test/java/org/embulk/parser/poi_excel/TestPoiExcelParserPlugin_mergedCell.java +94 -0
- data/src/test/java/org/embulk/parser/poi_excel/TestPoiExcelParserPlugin_sheets.java +35 -1
- metadata +30 -18
@@ -11,6 +11,9 @@ import org.embulk.parser.poi_excel.PoiExcelParserPlugin.ColumnCommonOptionTask;
|
|
11
11
|
import org.embulk.parser.poi_excel.PoiExcelParserPlugin.ColumnOptionTask;
|
12
12
|
import org.embulk.parser.poi_excel.PoiExcelParserPlugin.FormulaReplaceTask;
|
13
13
|
import org.embulk.parser.poi_excel.bean.PoiExcelColumnBean.ErrorStrategy.Strategy;
|
14
|
+
import org.embulk.parser.poi_excel.bean.util.PoiExcelCellAddress;
|
15
|
+
import org.embulk.parser.poi_excel.bean.util.SearchMergedCell;
|
16
|
+
import org.embulk.parser.poi_excel.visitor.util.MergedRegionFinder;
|
14
17
|
import org.embulk.spi.Column;
|
15
18
|
|
16
19
|
import com.google.common.base.Optional;
|
@@ -107,6 +110,25 @@ public class PoiExcelColumnBean {
|
|
107
110
|
return Optional.absent();
|
108
111
|
}
|
109
112
|
|
113
|
+
private Optional<PoiExcelCellAddress> cellAddress;
|
114
|
+
|
115
|
+
public PoiExcelCellAddress getCellAddress() {
|
116
|
+
if (cellAddress == null) {
|
117
|
+
this.cellAddress = initializeCellAddress();
|
118
|
+
}
|
119
|
+
return cellAddress.orNull();
|
120
|
+
}
|
121
|
+
|
122
|
+
protected Optional<PoiExcelCellAddress> initializeCellAddress() {
|
123
|
+
for (ColumnOptionTask task : columnTaskList) {
|
124
|
+
Optional<String> option = task.getCellAddress();
|
125
|
+
if (option.isPresent()) {
|
126
|
+
return Optional.of(new PoiExcelCellAddress(option.get()));
|
127
|
+
}
|
128
|
+
}
|
129
|
+
return Optional.absent();
|
130
|
+
}
|
131
|
+
|
110
132
|
protected abstract class CacheValue<T> {
|
111
133
|
private T value;
|
112
134
|
|
@@ -231,23 +253,105 @@ public class PoiExcelColumnBean {
|
|
231
253
|
return attributeName.get();
|
232
254
|
}
|
233
255
|
|
234
|
-
private CacheValue<
|
256
|
+
private CacheValue<String> numericFormat = new CacheValue<String>() {
|
235
257
|
|
236
258
|
@Override
|
237
|
-
protected Optional<
|
238
|
-
return task.
|
259
|
+
protected Optional<String> getTaskValue(ColumnCommonOptionTask task) {
|
260
|
+
return task.getNumericFormat();
|
239
261
|
}
|
240
262
|
|
241
263
|
@Override
|
242
|
-
protected
|
243
|
-
return
|
264
|
+
protected String getDefaultValue() {
|
265
|
+
return "";
|
244
266
|
}
|
245
267
|
};
|
246
268
|
|
247
|
-
public
|
269
|
+
public String getNumericFormat() {
|
270
|
+
return numericFormat.get();
|
271
|
+
}
|
272
|
+
|
273
|
+
private CacheValue<SearchMergedCell> searchMergedCell = new CacheValue<SearchMergedCell>() {
|
274
|
+
|
275
|
+
@Override
|
276
|
+
protected Optional<SearchMergedCell> getTaskValue(ColumnCommonOptionTask task) {
|
277
|
+
Optional<String> option = task.getSearchMergedCell();
|
278
|
+
String value = option.or("null").trim();
|
279
|
+
switch (value.toLowerCase()) {
|
280
|
+
case "null":
|
281
|
+
return Optional.absent();
|
282
|
+
case "true": // compatibility ver 0.1.7
|
283
|
+
return Optional.of(getDefaultValue());
|
284
|
+
case "false": // compatibility ver 0.1.7
|
285
|
+
return Optional.of(SearchMergedCell.NONE);
|
286
|
+
default:
|
287
|
+
break;
|
288
|
+
}
|
289
|
+
try {
|
290
|
+
return Optional.of(SearchMergedCell.valueOf(value.toUpperCase()));
|
291
|
+
} catch (Exception e) {
|
292
|
+
List<String> list = new ArrayList<>();
|
293
|
+
for (SearchMergedCell s : SearchMergedCell.values()) {
|
294
|
+
list.add(s.name().toLowerCase());
|
295
|
+
}
|
296
|
+
throw new ConfigException(MessageFormat.format("illegal search_merged_cell={0}. expected={1}", value,
|
297
|
+
list), e);
|
298
|
+
}
|
299
|
+
}
|
300
|
+
|
301
|
+
@Override
|
302
|
+
protected SearchMergedCell getDefaultValue() {
|
303
|
+
return SearchMergedCell.HASH_SEARCH;
|
304
|
+
}
|
305
|
+
};
|
306
|
+
|
307
|
+
public SearchMergedCell getSearchMergedCell() {
|
248
308
|
return searchMergedCell.get();
|
249
309
|
}
|
250
310
|
|
311
|
+
private MergedRegionFinder mergedRegionFinder;
|
312
|
+
|
313
|
+
public MergedRegionFinder getMergedRegionFinder() {
|
314
|
+
if (mergedRegionFinder == null) {
|
315
|
+
this.mergedRegionFinder = getSearchMergedCell().getMergedRegionFinder();
|
316
|
+
}
|
317
|
+
return mergedRegionFinder;
|
318
|
+
}
|
319
|
+
|
320
|
+
public enum FormulaHandling {
|
321
|
+
EVALUATE, CASHED_VALUE
|
322
|
+
}
|
323
|
+
|
324
|
+
private CacheValue<FormulaHandling> formulaHandling = new CacheValue<FormulaHandling>() {
|
325
|
+
|
326
|
+
@Override
|
327
|
+
protected Optional<FormulaHandling> getTaskValue(ColumnCommonOptionTask task) {
|
328
|
+
Optional<String> option = task.getFormulaHandling();
|
329
|
+
String value = option.or("null");
|
330
|
+
if ("null".equalsIgnoreCase(value)) {
|
331
|
+
return Optional.absent();
|
332
|
+
}
|
333
|
+
try {
|
334
|
+
return Optional.of(FormulaHandling.valueOf(value.trim().toUpperCase()));
|
335
|
+
} catch (Exception e) {
|
336
|
+
List<String> list = new ArrayList<>();
|
337
|
+
for (FormulaHandling s : FormulaHandling.values()) {
|
338
|
+
list.add(s.name().toLowerCase());
|
339
|
+
}
|
340
|
+
throw new ConfigException(MessageFormat.format("illegal formula_handling={0}. expected={1}", value,
|
341
|
+
list), e);
|
342
|
+
}
|
343
|
+
}
|
344
|
+
|
345
|
+
@Override
|
346
|
+
protected FormulaHandling getDefaultValue() {
|
347
|
+
return FormulaHandling.EVALUATE;
|
348
|
+
}
|
349
|
+
};
|
350
|
+
|
351
|
+
public FormulaHandling getFormulaHandling() {
|
352
|
+
return formulaHandling.get();
|
353
|
+
}
|
354
|
+
|
251
355
|
private CacheValue<List<FormulaReplaceTask>> formulaReplace = new CacheValue<List<FormulaReplaceTask>>() {
|
252
356
|
|
253
357
|
@Override
|
@@ -8,6 +8,7 @@ import java.util.Map;
|
|
8
8
|
import org.apache.poi.ss.util.CellReference;
|
9
9
|
import org.embulk.parser.poi_excel.PoiExcelColumnValueType;
|
10
10
|
import org.embulk.parser.poi_excel.PoiExcelParserPlugin.PluginTask;
|
11
|
+
import org.embulk.parser.poi_excel.bean.util.PoiExcelCellAddress;
|
11
12
|
import org.embulk.spi.Column;
|
12
13
|
import org.embulk.spi.Exec;
|
13
14
|
import org.embulk.spi.Schema;
|
@@ -36,43 +37,10 @@ public class PoiExcelColumnIndex {
|
|
36
37
|
}
|
37
38
|
bean.setColumnIndex(index);
|
38
39
|
indexMap.put(column.getName(), index);
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
String suffix = bean.getValueTypeSuffix();
|
44
|
-
if (suffix != null) {
|
45
|
-
log.info("column.name={} <- cell_column={}, value_type={}, value=[{}]", column.getName(),
|
46
|
-
c, valueType, suffix);
|
47
|
-
} else {
|
48
|
-
log.info("column.name={} <- cell_column={}, value_type={}, value={}", column.getName(), c,
|
49
|
-
valueType, suffix);
|
50
|
-
}
|
51
|
-
break;
|
52
|
-
case CELL_VALUE:
|
53
|
-
case CELL_FORMULA:
|
54
|
-
case COLUMN_NUMBER:
|
55
|
-
log.info("column.name={} <- cell_column={}, value_type={}", column.getName(), c, valueType);
|
56
|
-
break;
|
57
|
-
}
|
58
|
-
}
|
59
|
-
} else {
|
60
|
-
if (log.isInfoEnabled()) {
|
61
|
-
switch (valueType) {
|
62
|
-
default:
|
63
|
-
String suffix = bean.getValueTypeSuffix();
|
64
|
-
if (suffix != null) {
|
65
|
-
log.info("column.name={} <- value_type={}, value=[{}]", column.getName(), valueType, suffix);
|
66
|
-
} else {
|
67
|
-
log.info("column.name={} <- value_type={}, value={}", column.getName(), valueType, suffix);
|
68
|
-
}
|
69
|
-
break;
|
70
|
-
case SHEET_NAME:
|
71
|
-
case ROW_NUMBER:
|
72
|
-
log.info("column.name={} <- value_type={}", column.getName(), valueType);
|
73
|
-
break;
|
74
|
-
}
|
75
|
-
}
|
40
|
+
}
|
41
|
+
|
42
|
+
if (log.isInfoEnabled()) {
|
43
|
+
logColumn(column, bean, valueType, index);
|
76
44
|
}
|
77
45
|
}
|
78
46
|
}
|
@@ -80,6 +48,15 @@ public class PoiExcelColumnIndex {
|
|
80
48
|
protected int resolveColumnIndex(Column column, PoiExcelColumnBean bean, int index,
|
81
49
|
PoiExcelColumnValueType valueType) {
|
82
50
|
Optional<String> numberOption = bean.getColumnNumber();
|
51
|
+
PoiExcelCellAddress cellAddress = bean.getCellAddress();
|
52
|
+
|
53
|
+
if (cellAddress != null) {
|
54
|
+
if (numberOption.isPresent()) {
|
55
|
+
throw new RuntimeException("only one of column_number, cell_address can be specified");
|
56
|
+
}
|
57
|
+
return index;
|
58
|
+
}
|
59
|
+
|
83
60
|
if (numberOption.isPresent()) {
|
84
61
|
String columnNumber = numberOption.get();
|
85
62
|
if (columnNumber.length() >= 1) {
|
@@ -190,4 +167,64 @@ public class PoiExcelColumnIndex {
|
|
190
167
|
}
|
191
168
|
return index;
|
192
169
|
}
|
170
|
+
|
171
|
+
protected void logColumn(Column column, PoiExcelColumnBean bean, PoiExcelColumnValueType valueType, int index) {
|
172
|
+
PoiExcelCellAddress cellAddress = bean.getCellAddress();
|
173
|
+
|
174
|
+
String cname, cvalue;
|
175
|
+
if (cellAddress != null) {
|
176
|
+
cname = "cell_address";
|
177
|
+
cvalue = cellAddress.getString();
|
178
|
+
} else {
|
179
|
+
cname = "cell_column";
|
180
|
+
cvalue = CellReference.convertNumToColString(index);
|
181
|
+
}
|
182
|
+
|
183
|
+
switch (valueType) {
|
184
|
+
default:
|
185
|
+
case CELL_VALUE:
|
186
|
+
case CELL_FORMULA:
|
187
|
+
case CELL_TYPE:
|
188
|
+
case CELL_CACHED_TYPE:
|
189
|
+
case COLUMN_NUMBER:
|
190
|
+
log.info("column.name={} <- {}={}, value_type={}", column.getName(), cname, cvalue, valueType);
|
191
|
+
break;
|
192
|
+
case CELL_STYLE:
|
193
|
+
case CELL_FONT:
|
194
|
+
case CELL_COMMENT:
|
195
|
+
String suffix = bean.getValueTypeSuffix();
|
196
|
+
if (suffix != null) {
|
197
|
+
log.info("column.name={} <- {}={}, value_type={}, value=[{}]", column.getName(), cname, cvalue,
|
198
|
+
valueType, suffix);
|
199
|
+
} else {
|
200
|
+
log.info("column.name={} <- {}={}, value_type={}, value={}", column.getName(), cname, cvalue,
|
201
|
+
valueType, suffix);
|
202
|
+
}
|
203
|
+
break;
|
204
|
+
|
205
|
+
case SHEET_NAME:
|
206
|
+
if (cellAddress != null && cellAddress.getSheetName() != null) {
|
207
|
+
log.info("column.name={} <- {}={}, value_type={}", column.getName(), cname, cvalue, valueType);
|
208
|
+
} else {
|
209
|
+
log.info("column.name={} <- value_type={}", column.getName(), valueType);
|
210
|
+
}
|
211
|
+
break;
|
212
|
+
case ROW_NUMBER:
|
213
|
+
if (cellAddress != null) {
|
214
|
+
log.info("column.name={} <- {}={}, value_type={}", column.getName(), cname, cvalue, valueType);
|
215
|
+
} else {
|
216
|
+
log.info("column.name={} <- value_type={}", column.getName(), valueType);
|
217
|
+
}
|
218
|
+
break;
|
219
|
+
|
220
|
+
case CONSTANT:
|
221
|
+
String value = bean.getValueTypeSuffix();
|
222
|
+
if (value != null) {
|
223
|
+
log.info("column.name={} <- value_type={}, value=[{}]", column.getName(), valueType, value);
|
224
|
+
} else {
|
225
|
+
log.info("column.name={} <- value_type={}, value={}", column.getName(), valueType, value);
|
226
|
+
}
|
227
|
+
break;
|
228
|
+
}
|
229
|
+
}
|
193
230
|
}
|
@@ -0,0 +1,50 @@
|
|
1
|
+
package org.embulk.parser.poi_excel.bean.util;
|
2
|
+
|
3
|
+
import java.text.MessageFormat;
|
4
|
+
|
5
|
+
import org.apache.poi.ss.usermodel.Cell;
|
6
|
+
import org.apache.poi.ss.usermodel.Row;
|
7
|
+
import org.apache.poi.ss.usermodel.Sheet;
|
8
|
+
import org.apache.poi.ss.usermodel.Workbook;
|
9
|
+
import org.apache.poi.ss.util.CellReference;
|
10
|
+
|
11
|
+
public class PoiExcelCellAddress {
|
12
|
+
private final CellReference cellReference;
|
13
|
+
|
14
|
+
public PoiExcelCellAddress(String cellAddress) {
|
15
|
+
this.cellReference = new CellReference(cellAddress);
|
16
|
+
}
|
17
|
+
|
18
|
+
public String getSheetName() {
|
19
|
+
return cellReference.getSheetName();
|
20
|
+
}
|
21
|
+
|
22
|
+
public Sheet getSheet(Row currentRow) {
|
23
|
+
String sheetName = getSheetName();
|
24
|
+
if (sheetName != null) {
|
25
|
+
Workbook book = currentRow.getSheet().getWorkbook();
|
26
|
+
Sheet sheet = book.getSheet(sheetName);
|
27
|
+
if (sheet == null) {
|
28
|
+
throw new RuntimeException(MessageFormat.format("not found sheet. sheetName={0}", sheetName));
|
29
|
+
}
|
30
|
+
return sheet;
|
31
|
+
} else {
|
32
|
+
return currentRow.getSheet();
|
33
|
+
}
|
34
|
+
}
|
35
|
+
|
36
|
+
public Cell getCell(Row currentRow) {
|
37
|
+
Sheet sheet = getSheet(currentRow);
|
38
|
+
|
39
|
+
Row row = sheet.getRow(cellReference.getRow());
|
40
|
+
if (row == null) {
|
41
|
+
return null;
|
42
|
+
}
|
43
|
+
|
44
|
+
return row.getCell(cellReference.getCol());
|
45
|
+
}
|
46
|
+
|
47
|
+
public String getString() {
|
48
|
+
return cellReference.formatAsString();
|
49
|
+
}
|
50
|
+
}
|
@@ -0,0 +1,71 @@
|
|
1
|
+
package org.embulk.parser.poi_excel.bean.util;
|
2
|
+
|
3
|
+
import java.util.HashMap;
|
4
|
+
import java.util.Map;
|
5
|
+
import java.util.TreeMap;
|
6
|
+
|
7
|
+
import org.apache.poi.ss.util.CellRangeAddress;
|
8
|
+
import org.embulk.parser.poi_excel.visitor.util.MergedRegionFinder;
|
9
|
+
import org.embulk.parser.poi_excel.visitor.util.MergedRegionList;
|
10
|
+
import org.embulk.parser.poi_excel.visitor.util.MergedRegionMap;
|
11
|
+
import org.embulk.parser.poi_excel.visitor.util.MergedRegionNothing;
|
12
|
+
|
13
|
+
public enum SearchMergedCell {
|
14
|
+
NONE {
|
15
|
+
@Override
|
16
|
+
public MergedRegionFinder createMergedRegionFinder() {
|
17
|
+
return new MergedRegionNothing();
|
18
|
+
}
|
19
|
+
},
|
20
|
+
LINEAR_SEARCH {
|
21
|
+
@Override
|
22
|
+
public MergedRegionFinder createMergedRegionFinder() {
|
23
|
+
return new MergedRegionList();
|
24
|
+
}
|
25
|
+
},
|
26
|
+
TREE_SEARCH {
|
27
|
+
@Override
|
28
|
+
public MergedRegionFinder createMergedRegionFinder() {
|
29
|
+
return new MergedRegionMap() {
|
30
|
+
|
31
|
+
@Override
|
32
|
+
protected Map<Integer, Map<Integer, CellRangeAddress>> newRowMap() {
|
33
|
+
return new TreeMap<>();
|
34
|
+
}
|
35
|
+
|
36
|
+
@Override
|
37
|
+
protected Map<Integer, CellRangeAddress> newColumnMap() {
|
38
|
+
return new TreeMap<>();
|
39
|
+
}
|
40
|
+
};
|
41
|
+
}
|
42
|
+
},
|
43
|
+
HASH_SEARCH {
|
44
|
+
@Override
|
45
|
+
public MergedRegionFinder createMergedRegionFinder() {
|
46
|
+
return new MergedRegionMap() {
|
47
|
+
|
48
|
+
@Override
|
49
|
+
protected Map<Integer, Map<Integer, CellRangeAddress>> newRowMap() {
|
50
|
+
return new HashMap<>();
|
51
|
+
}
|
52
|
+
|
53
|
+
@Override
|
54
|
+
protected Map<Integer, CellRangeAddress> newColumnMap() {
|
55
|
+
return new HashMap<>();
|
56
|
+
}
|
57
|
+
};
|
58
|
+
}
|
59
|
+
};
|
60
|
+
|
61
|
+
private MergedRegionFinder mergedRegionFinder;
|
62
|
+
|
63
|
+
public MergedRegionFinder getMergedRegionFinder() {
|
64
|
+
if (mergedRegionFinder == null) {
|
65
|
+
this.mergedRegionFinder = createMergedRegionFinder();
|
66
|
+
}
|
67
|
+
return mergedRegionFinder;
|
68
|
+
}
|
69
|
+
|
70
|
+
protected abstract MergedRegionFinder createMergedRegionFinder();
|
71
|
+
}
|
@@ -100,12 +100,6 @@ public class PoiExcelCellFontVisitor extends AbstractPoiExcelCellAttributeVisito
|
|
100
100
|
return (long) font.getIndex();
|
101
101
|
}
|
102
102
|
});
|
103
|
-
map.put("boldweight", new AttributeSupplier<Font>() {
|
104
|
-
@Override
|
105
|
-
public Object get(Column column, Cell cell, Font font) {
|
106
|
-
return (long) font.getBoldweight();
|
107
|
-
}
|
108
|
-
});
|
109
103
|
map.put("bold", new AttributeSupplier<Font>() {
|
110
104
|
@Override
|
111
105
|
public Object get(Column column, Cell cell, Font font) {
|
@@ -41,16 +41,16 @@ public class PoiExcelCellStyleVisitor extends AbstractPoiExcelCellAttributeVisit
|
|
41
41
|
map.put("alignment", new AttributeSupplier<CellStyle>() {
|
42
42
|
@Override
|
43
43
|
public Object get(Column column, Cell cell, CellStyle style) {
|
44
|
-
return (long) style.
|
44
|
+
return (long) style.getAlignmentEnum().getCode();
|
45
45
|
}
|
46
46
|
});
|
47
47
|
map.put("border", new AttributeSupplier<CellStyle>() {
|
48
48
|
@Override
|
49
49
|
public Object get(Column column, Cell cell, CellStyle style) {
|
50
|
-
int n0 = style.
|
51
|
-
int n1 = style.
|
52
|
-
int n2 = style.
|
53
|
-
int n3 = style.
|
50
|
+
int n0 = style.getBorderTopEnum().getCode();
|
51
|
+
int n1 = style.getBorderBottomEnum().getCode();
|
52
|
+
int n2 = style.getBorderLeftEnum().getCode();
|
53
|
+
int n3 = style.getBorderRightEnum().getCode();
|
54
54
|
if (column.getType() instanceof StringType) {
|
55
55
|
return String.format("%02x%02x%02x%02x", n0, n1, n2, n3);
|
56
56
|
}
|
@@ -60,25 +60,25 @@ public class PoiExcelCellStyleVisitor extends AbstractPoiExcelCellAttributeVisit
|
|
60
60
|
map.put("border_bottom", new AttributeSupplier<CellStyle>() {
|
61
61
|
@Override
|
62
62
|
public Object get(Column column, Cell cell, CellStyle style) {
|
63
|
-
return (long) style.
|
63
|
+
return (long) style.getBorderBottomEnum().getCode();
|
64
64
|
}
|
65
65
|
});
|
66
66
|
map.put("border_left", new AttributeSupplier<CellStyle>() {
|
67
67
|
@Override
|
68
68
|
public Object get(Column column, Cell cell, CellStyle style) {
|
69
|
-
return (long) style.
|
69
|
+
return (long) style.getBorderLeftEnum().getCode();
|
70
70
|
}
|
71
71
|
});
|
72
72
|
map.put("border_right", new AttributeSupplier<CellStyle>() {
|
73
73
|
@Override
|
74
74
|
public Object get(Column column, Cell cell, CellStyle style) {
|
75
|
-
return (long) style.
|
75
|
+
return (long) style.getBorderRightEnum().getCode();
|
76
76
|
}
|
77
77
|
});
|
78
78
|
map.put("border_top", new AttributeSupplier<CellStyle>() {
|
79
79
|
@Override
|
80
80
|
public Object get(Column column, Cell cell, CellStyle style) {
|
81
|
-
return (long) style.
|
81
|
+
return (long) style.getBorderTopEnum().getCode();
|
82
82
|
}
|
83
83
|
});
|
84
84
|
map.put("border_bottom_color", new AttributeSupplier<CellStyle>() {
|
@@ -154,7 +154,7 @@ public class PoiExcelCellStyleVisitor extends AbstractPoiExcelCellAttributeVisit
|
|
154
154
|
map.put("fill_pattern", new AttributeSupplier<CellStyle>() {
|
155
155
|
@Override
|
156
156
|
public Object get(Column column, Cell cell, CellStyle style) {
|
157
|
-
return (long) style.
|
157
|
+
return (long) style.getFillPatternEnum().getCode();
|
158
158
|
}
|
159
159
|
});
|
160
160
|
map.put("font_index", new AttributeSupplier<CellStyle>() {
|
@@ -190,7 +190,7 @@ public class PoiExcelCellStyleVisitor extends AbstractPoiExcelCellAttributeVisit
|
|
190
190
|
map.put("vertical_alignment", new AttributeSupplier<CellStyle>() {
|
191
191
|
@Override
|
192
192
|
public Object get(Column column, Cell cell, CellStyle style) {
|
193
|
-
return (long) style.
|
193
|
+
return (long) style.getVerticalAlignmentEnum().getCode();
|
194
194
|
}
|
195
195
|
});
|
196
196
|
map.put("wrap_text", new AttributeSupplier<CellStyle>() {
|