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
@@ -1,8 +1,11 @@
|
|
1
1
|
package org.embulk.parser.poi_excel.visitor.embulk;
|
2
2
|
|
3
|
+
import java.text.MessageFormat;
|
4
|
+
|
3
5
|
import org.apache.poi.ss.usermodel.FormulaError;
|
4
6
|
import org.apache.poi.ss.usermodel.Sheet;
|
5
7
|
import org.apache.poi.ss.util.CellReference;
|
8
|
+
import org.embulk.parser.poi_excel.bean.PoiExcelColumnBean;
|
6
9
|
import org.embulk.parser.poi_excel.visitor.PoiExcelVisitorValue;
|
7
10
|
import org.embulk.spi.Column;
|
8
11
|
|
@@ -14,11 +17,31 @@ public class StringCellVisitor extends CellVisitor {
|
|
14
17
|
|
15
18
|
@Override
|
16
19
|
public void visitCellValueNumeric(Column column, Object source, double value) {
|
20
|
+
String s = toString(column, source, value);
|
21
|
+
pageBuilder.setString(column, s);
|
22
|
+
}
|
23
|
+
|
24
|
+
protected String toString(Column column, Object source, double value) {
|
25
|
+
String format = getNumericFormat(column);
|
26
|
+
if (!format.isEmpty()) {
|
27
|
+
try {
|
28
|
+
return String.format(format, value);
|
29
|
+
} catch (Exception e) {
|
30
|
+
throw new IllegalArgumentException(MessageFormat.format(
|
31
|
+
"illegal String.format for double. numeric_format=\"{0}\"", format), e);
|
32
|
+
}
|
33
|
+
}
|
34
|
+
|
17
35
|
String s = Double.toString(value);
|
18
36
|
if (s.endsWith(".0")) {
|
19
|
-
|
37
|
+
return s.substring(0, s.length() - 2);
|
20
38
|
}
|
21
|
-
|
39
|
+
return s;
|
40
|
+
}
|
41
|
+
|
42
|
+
protected String getNumericFormat(Column column) {
|
43
|
+
PoiExcelColumnBean bean = visitorValue.getColumnBean(column);
|
44
|
+
return bean.getNumericFormat();
|
22
45
|
}
|
23
46
|
|
24
47
|
@Override
|
@@ -47,6 +70,11 @@ public class StringCellVisitor extends CellVisitor {
|
|
47
70
|
@Override
|
48
71
|
public void visitSheetName(Column column) {
|
49
72
|
Sheet sheet = visitorValue.getSheet();
|
73
|
+
visitSheetName(column, sheet);
|
74
|
+
}
|
75
|
+
|
76
|
+
@Override
|
77
|
+
public void visitSheetName(Column column, Sheet sheet) {
|
50
78
|
pageBuilder.setString(column, sheet.getSheetName());
|
51
79
|
}
|
52
80
|
|
@@ -61,6 +61,11 @@ public class TimestampCellVisitor extends CellVisitor {
|
|
61
61
|
@Override
|
62
62
|
public void visitSheetName(Column column) {
|
63
63
|
Sheet sheet = visitorValue.getSheet();
|
64
|
+
visitSheetName(column, sheet);
|
65
|
+
}
|
66
|
+
|
67
|
+
@Override
|
68
|
+
public void visitSheetName(Column column, Sheet sheet) {
|
64
69
|
doConvertError(column, sheet.getSheetName(), new UnsupportedOperationException(
|
65
70
|
"unsupported conversion sheet_name to Embulk timestamp"));
|
66
71
|
}
|
@@ -0,0 +1,9 @@
|
|
1
|
+
package org.embulk.parser.poi_excel.visitor.util;
|
2
|
+
|
3
|
+
import org.apache.poi.ss.usermodel.Sheet;
|
4
|
+
import org.apache.poi.ss.util.CellRangeAddress;
|
5
|
+
|
6
|
+
public interface MergedRegionFinder {
|
7
|
+
|
8
|
+
public CellRangeAddress get(Sheet sheet, int rowIndex, int columnIndex);
|
9
|
+
}
|
@@ -0,0 +1,20 @@
|
|
1
|
+
package org.embulk.parser.poi_excel.visitor.util;
|
2
|
+
|
3
|
+
import org.apache.poi.ss.usermodel.Sheet;
|
4
|
+
import org.apache.poi.ss.util.CellRangeAddress;
|
5
|
+
|
6
|
+
public class MergedRegionList implements MergedRegionFinder {
|
7
|
+
|
8
|
+
@Override
|
9
|
+
public CellRangeAddress get(Sheet sheet, int rowIndex, int columnIndex) {
|
10
|
+
int size = sheet.getNumMergedRegions();
|
11
|
+
for (int i = 0; i < size; i++) {
|
12
|
+
CellRangeAddress region = sheet.getMergedRegion(i);
|
13
|
+
if (region.isInRange(rowIndex, columnIndex)) {
|
14
|
+
return region;
|
15
|
+
}
|
16
|
+
}
|
17
|
+
|
18
|
+
return null;
|
19
|
+
}
|
20
|
+
}
|
@@ -0,0 +1,55 @@
|
|
1
|
+
package org.embulk.parser.poi_excel.visitor.util;
|
2
|
+
|
3
|
+
import java.util.Map;
|
4
|
+
import java.util.concurrent.ConcurrentHashMap;
|
5
|
+
|
6
|
+
import org.apache.poi.ss.usermodel.Sheet;
|
7
|
+
import org.apache.poi.ss.util.CellRangeAddress;
|
8
|
+
|
9
|
+
public abstract class MergedRegionMap implements MergedRegionFinder {
|
10
|
+
|
11
|
+
private final Map<Sheet, Map<Integer, Map<Integer, CellRangeAddress>>> sheetMap = new ConcurrentHashMap<>();
|
12
|
+
|
13
|
+
@Override
|
14
|
+
public CellRangeAddress get(Sheet sheet, int rowIndex, int columnIndex) {
|
15
|
+
Map<Integer, Map<Integer, CellRangeAddress>> rowMap = sheetMap.get(sheet);
|
16
|
+
if (rowMap == null) {
|
17
|
+
synchronized (sheet) {
|
18
|
+
rowMap = createRowMap(sheet);
|
19
|
+
sheetMap.put(sheet, rowMap);
|
20
|
+
}
|
21
|
+
}
|
22
|
+
|
23
|
+
Map<Integer, CellRangeAddress> columnMap = rowMap.get(rowIndex);
|
24
|
+
if (columnMap == null) {
|
25
|
+
return null;
|
26
|
+
}
|
27
|
+
return columnMap.get(columnIndex);
|
28
|
+
}
|
29
|
+
|
30
|
+
protected Map<Integer, Map<Integer, CellRangeAddress>> createRowMap(Sheet sheet) {
|
31
|
+
Map<Integer, Map<Integer, CellRangeAddress>> rowMap = newRowMap();
|
32
|
+
|
33
|
+
for (int i = sheet.getNumMergedRegions() - 1; i >= 0; i--) {
|
34
|
+
CellRangeAddress region = sheet.getMergedRegion(i);
|
35
|
+
|
36
|
+
for (int r = region.getFirstRow(); r <= region.getLastRow(); r++) {
|
37
|
+
Map<Integer, CellRangeAddress> columnMap = rowMap.get(r);
|
38
|
+
if (columnMap == null) {
|
39
|
+
columnMap = newColumnMap();
|
40
|
+
rowMap.put(r, columnMap);
|
41
|
+
}
|
42
|
+
|
43
|
+
for (int c = region.getFirstColumn(); c <= region.getLastColumn(); c++) {
|
44
|
+
columnMap.put(c, region);
|
45
|
+
}
|
46
|
+
}
|
47
|
+
}
|
48
|
+
|
49
|
+
return rowMap;
|
50
|
+
}
|
51
|
+
|
52
|
+
protected abstract Map<Integer, Map<Integer, CellRangeAddress>> newRowMap();
|
53
|
+
|
54
|
+
protected abstract Map<Integer, CellRangeAddress> newColumnMap();
|
55
|
+
}
|
@@ -0,0 +1,12 @@
|
|
1
|
+
package org.embulk.parser.poi_excel.visitor.util;
|
2
|
+
|
3
|
+
import org.apache.poi.ss.usermodel.Sheet;
|
4
|
+
import org.apache.poi.ss.util.CellRangeAddress;
|
5
|
+
|
6
|
+
public class MergedRegionNothing implements MergedRegionFinder {
|
7
|
+
|
8
|
+
@Override
|
9
|
+
public CellRangeAddress get(Sheet sheet, int rowIndex, int columnIndex) {
|
10
|
+
return null;
|
11
|
+
}
|
12
|
+
}
|
@@ -1,7 +1,7 @@
|
|
1
1
|
package org.embulk.parser.poi_excel;
|
2
2
|
|
3
3
|
import static org.hamcrest.CoreMatchers.is;
|
4
|
-
import static org.
|
4
|
+
import static org.hamcrest.MatcherAssert.assertThat;
|
5
5
|
|
6
6
|
import java.net.URL;
|
7
7
|
import java.text.ParseException;
|
@@ -10,7 +10,6 @@ import java.util.Arrays;
|
|
10
10
|
import java.util.List;
|
11
11
|
import java.util.TimeZone;
|
12
12
|
|
13
|
-
import org.embulk.config.ConfigSource;
|
14
13
|
import org.embulk.parser.EmbulkPluginTester;
|
15
14
|
import org.embulk.parser.EmbulkTestOutputPlugin.OutputRecord;
|
16
15
|
import org.embulk.parser.EmbulkTestParserConfig;
|
@@ -74,6 +73,32 @@ public class TestPoiExcelParserPlugin {
|
|
74
73
|
assertThat(r.getAsTimestamp("timestamp"), is(timestamp));
|
75
74
|
}
|
76
75
|
|
76
|
+
@Theory
|
77
|
+
public void testNumricFormat(String excelFile) throws ParseException {
|
78
|
+
try (EmbulkPluginTester tester = new EmbulkPluginTester()) {
|
79
|
+
tester.addParserPlugin(PoiExcelParserPlugin.TYPE, PoiExcelParserPlugin.class);
|
80
|
+
|
81
|
+
EmbulkTestParserConfig parser = tester.newParserConfig(PoiExcelParserPlugin.TYPE);
|
82
|
+
parser.set("sheets", Arrays.asList("test1"));
|
83
|
+
parser.set("skip_header_lines", 1);
|
84
|
+
parser.addColumn("value", "string").set("column_number", "C").set("numeric_format", "%.2f");
|
85
|
+
|
86
|
+
URL inFile = getClass().getResource(excelFile);
|
87
|
+
List<OutputRecord> result = tester.runParser(inFile, parser);
|
88
|
+
|
89
|
+
assertThat(result.size(), is(7));
|
90
|
+
checkNumricFormat(result, 0, "123.40");
|
91
|
+
checkNumricFormat(result, 1, "456.70");
|
92
|
+
checkNumricFormat(result, 2, "123.00");
|
93
|
+
}
|
94
|
+
}
|
95
|
+
|
96
|
+
private void checkNumricFormat(List<OutputRecord> result, int index, String s) {
|
97
|
+
OutputRecord r = result.get(index);
|
98
|
+
// System.out.println(r);
|
99
|
+
assertThat(r.getAsString("value"), is(s));
|
100
|
+
}
|
101
|
+
|
77
102
|
@Theory
|
78
103
|
public void testRowNumber(String excelFile) throws ParseException {
|
79
104
|
try (EmbulkPluginTester tester = new EmbulkPluginTester()) {
|
@@ -114,83 +139,6 @@ public class TestPoiExcelParserPlugin {
|
|
114
139
|
assertThat(r.getAsString("col-s"), is("A"));
|
115
140
|
}
|
116
141
|
|
117
|
-
@Theory
|
118
|
-
public void testForumlaReplace(String excelFile) throws ParseException {
|
119
|
-
try (EmbulkPluginTester tester = new EmbulkPluginTester()) {
|
120
|
-
tester.addParserPlugin(PoiExcelParserPlugin.TYPE, PoiExcelParserPlugin.class);
|
121
|
-
|
122
|
-
EmbulkTestParserConfig parser = tester.newParserConfig(PoiExcelParserPlugin.TYPE);
|
123
|
-
parser.set("sheet", "formula_replace");
|
124
|
-
|
125
|
-
ConfigSource replace0 = tester.newConfigSource();
|
126
|
-
replace0.set("regex", "test1");
|
127
|
-
replace0.set("to", "merged_cell");
|
128
|
-
ConfigSource replace1 = tester.newConfigSource();
|
129
|
-
replace1.set("regex", "B1");
|
130
|
-
replace1.set("to", "B${row}");
|
131
|
-
parser.set("formula_replace", Arrays.asList(replace0, replace1));
|
132
|
-
|
133
|
-
parser.addColumn("text", "string");
|
134
|
-
|
135
|
-
URL inFile = getClass().getResource(excelFile);
|
136
|
-
List<OutputRecord> result = tester.runParser(inFile, parser);
|
137
|
-
|
138
|
-
assertThat(result.size(), is(2));
|
139
|
-
assertThat(result.get(0).getAsString("text"), is("test3-a1"));
|
140
|
-
assertThat(result.get(1).getAsString("text"), is("test2-b2"));
|
141
|
-
}
|
142
|
-
}
|
143
|
-
|
144
|
-
@Theory
|
145
|
-
public void testSearchMergedCell_true(String excelFile) throws ParseException {
|
146
|
-
try (EmbulkPluginTester tester = new EmbulkPluginTester()) {
|
147
|
-
tester.addParserPlugin(PoiExcelParserPlugin.TYPE, PoiExcelParserPlugin.class);
|
148
|
-
|
149
|
-
EmbulkTestParserConfig parser = tester.newParserConfig(PoiExcelParserPlugin.TYPE);
|
150
|
-
parser.set("sheet", "merged_cell");
|
151
|
-
parser.addColumn("a", "string");
|
152
|
-
parser.addColumn("b", "string");
|
153
|
-
|
154
|
-
URL inFile = getClass().getResource(excelFile);
|
155
|
-
List<OutputRecord> result = tester.runParser(inFile, parser);
|
156
|
-
|
157
|
-
assertThat(result.size(), is(4));
|
158
|
-
check6(result, 0, "test3-a1", "test3-a1");
|
159
|
-
check6(result, 1, "data", "0");
|
160
|
-
check6(result, 2, null, null);
|
161
|
-
check6(result, 3, null, null);
|
162
|
-
}
|
163
|
-
}
|
164
|
-
|
165
|
-
@Theory
|
166
|
-
public void testSearchMergedCell_false(String excelFile) throws ParseException {
|
167
|
-
try (EmbulkPluginTester tester = new EmbulkPluginTester()) {
|
168
|
-
tester.addParserPlugin(PoiExcelParserPlugin.TYPE, PoiExcelParserPlugin.class);
|
169
|
-
|
170
|
-
EmbulkTestParserConfig parser = tester.newParserConfig(PoiExcelParserPlugin.TYPE);
|
171
|
-
parser.set("sheet", "merged_cell");
|
172
|
-
parser.set("search_merged_cell", false);
|
173
|
-
parser.addColumn("a", "string");
|
174
|
-
parser.addColumn("b", "string");
|
175
|
-
|
176
|
-
URL inFile = getClass().getResource(excelFile);
|
177
|
-
List<OutputRecord> result = tester.runParser(inFile, parser);
|
178
|
-
|
179
|
-
assertThat(result.size(), is(4));
|
180
|
-
check6(result, 0, "test3-a1", null);
|
181
|
-
check6(result, 1, "data", "0");
|
182
|
-
check6(result, 2, null, null);
|
183
|
-
check6(result, 3, null, null);
|
184
|
-
}
|
185
|
-
}
|
186
|
-
|
187
|
-
private void check6(List<OutputRecord> result, int index, String a, String b) {
|
188
|
-
OutputRecord r = result.get(index);
|
189
|
-
// System.out.println(r);
|
190
|
-
assertThat(r.getAsString("a"), is(a));
|
191
|
-
assertThat(r.getAsString("b"), is(b));
|
192
|
-
}
|
193
|
-
|
194
142
|
@Theory
|
195
143
|
public void test_sheets(String excelFile) throws ParseException {
|
196
144
|
try (EmbulkPluginTester tester = new EmbulkPluginTester()) {
|
@@ -0,0 +1,69 @@
|
|
1
|
+
package org.embulk.parser.poi_excel;
|
2
|
+
|
3
|
+
import static org.hamcrest.CoreMatchers.is;
|
4
|
+
import static org.hamcrest.MatcherAssert.assertThat;
|
5
|
+
|
6
|
+
import java.net.URL;
|
7
|
+
import java.text.ParseException;
|
8
|
+
import java.util.List;
|
9
|
+
|
10
|
+
import org.embulk.parser.EmbulkPluginTester;
|
11
|
+
import org.embulk.parser.EmbulkTestOutputPlugin.OutputRecord;
|
12
|
+
import org.embulk.parser.EmbulkTestParserConfig;
|
13
|
+
import org.junit.experimental.theories.DataPoints;
|
14
|
+
import org.junit.experimental.theories.Theories;
|
15
|
+
import org.junit.experimental.theories.Theory;
|
16
|
+
import org.junit.runner.RunWith;
|
17
|
+
|
18
|
+
@RunWith(Theories.class)
|
19
|
+
public class TestPoiExcelParserPlugin_cellAddress {
|
20
|
+
|
21
|
+
@DataPoints
|
22
|
+
public static String[] FILES = { "test1.xls", "test2.xlsx" };
|
23
|
+
|
24
|
+
@Theory
|
25
|
+
public void testCellAddress(String excelFile) throws ParseException {
|
26
|
+
try (EmbulkPluginTester tester = new EmbulkPluginTester()) {
|
27
|
+
tester.addParserPlugin(PoiExcelParserPlugin.TYPE, PoiExcelParserPlugin.class);
|
28
|
+
|
29
|
+
EmbulkTestParserConfig parser = tester.newParserConfig(PoiExcelParserPlugin.TYPE);
|
30
|
+
parser.set("sheet", "test1");
|
31
|
+
parser.set("skip_header_lines", 1);
|
32
|
+
parser.addColumn("text", "string").set("column_number", "D");
|
33
|
+
parser.addColumn("fix_value", "string").set("cell_address", "B1").set("value", "cell_value");
|
34
|
+
parser.addColumn("fix_sheet", "string").set("cell_address", "B1").set("value", "sheet_name");
|
35
|
+
parser.addColumn("fix_row", "long").set("cell_address", "B1").set("value", "row_number");
|
36
|
+
parser.addColumn("fix_col", "long").set("cell_address", "B1").set("value", "column_number");
|
37
|
+
parser.addColumn("other_sheet_value", "string").set("cell_address", "style!B5").set("value", "cell_value");
|
38
|
+
parser.addColumn("other_sheet_name", "string").set("cell_address", "style!B5").set("value", "sheet_name");
|
39
|
+
parser.addColumn("other_sheet_row", "long").set("cell_address", "style!B5").set("value", "row_number");
|
40
|
+
parser.addColumn("other_sheet_col", "string").set("cell_address", "style!B5").set("value", "column_number");
|
41
|
+
|
42
|
+
URL inFile = getClass().getResource(excelFile);
|
43
|
+
List<OutputRecord> result = tester.runParser(inFile, parser);
|
44
|
+
|
45
|
+
assertThat(result.size(), is(7));
|
46
|
+
check1(result, 0, "abc");
|
47
|
+
check1(result, 1, "def");
|
48
|
+
check1(result, 2, "456");
|
49
|
+
check1(result, 3, "abc");
|
50
|
+
check1(result, 4, "abc");
|
51
|
+
check1(result, 5, "true");
|
52
|
+
check1(result, 6, null);
|
53
|
+
}
|
54
|
+
}
|
55
|
+
|
56
|
+
private void check1(List<OutputRecord> result, int index, String text) {
|
57
|
+
OutputRecord record = result.get(index);
|
58
|
+
// System.out.println(record);
|
59
|
+
assertThat(record.getAsString("text"), is(text));
|
60
|
+
assertThat(record.getAsString("fix_value"), is("long"));
|
61
|
+
assertThat(record.getAsString("fix_sheet"), is("test1"));
|
62
|
+
assertThat(record.getAsLong("fix_row"), is(1L));
|
63
|
+
assertThat(record.getAsLong("fix_col"), is(2L));
|
64
|
+
assertThat(record.getAsString("other_sheet_value"), is("bottom"));
|
65
|
+
assertThat(record.getAsString("other_sheet_name"), is("style"));
|
66
|
+
assertThat(record.getAsLong("other_sheet_row"), is(5L));
|
67
|
+
assertThat(record.getAsString("other_sheet_col"), is("B"));
|
68
|
+
}
|
69
|
+
}
|
@@ -2,7 +2,7 @@ package org.embulk.parser.poi_excel;
|
|
2
2
|
|
3
3
|
import static org.hamcrest.CoreMatchers.is;
|
4
4
|
import static org.hamcrest.CoreMatchers.nullValue;
|
5
|
-
import static org.
|
5
|
+
import static org.hamcrest.MatcherAssert.assertThat;
|
6
6
|
import static org.junit.Assert.fail;
|
7
7
|
|
8
8
|
import java.net.URL;
|
@@ -2,7 +2,7 @@ package org.embulk.parser.poi_excel;
|
|
2
2
|
|
3
3
|
import static org.hamcrest.CoreMatchers.is;
|
4
4
|
import static org.hamcrest.CoreMatchers.nullValue;
|
5
|
-
import static org.
|
5
|
+
import static org.hamcrest.MatcherAssert.assertThat;
|
6
6
|
import static org.junit.Assert.fail;
|
7
7
|
|
8
8
|
import java.net.URL;
|
@@ -2,7 +2,7 @@ package org.embulk.parser.poi_excel;
|
|
2
2
|
|
3
3
|
import static org.hamcrest.CoreMatchers.is;
|
4
4
|
import static org.hamcrest.CoreMatchers.nullValue;
|
5
|
-
import static org.
|
5
|
+
import static org.hamcrest.MatcherAssert.assertThat;
|
6
6
|
import static org.junit.Assert.fail;
|
7
7
|
|
8
8
|
import java.net.URL;
|
@@ -1,7 +1,7 @@
|
|
1
1
|
package org.embulk.parser.poi_excel;
|
2
2
|
|
3
3
|
import static org.hamcrest.CoreMatchers.is;
|
4
|
-
import static org.
|
4
|
+
import static org.hamcrest.MatcherAssert.assertThat;
|
5
5
|
import static org.junit.Assert.fail;
|
6
6
|
|
7
7
|
import java.net.URL;
|
@@ -9,7 +9,7 @@ import java.text.ParseException;
|
|
9
9
|
import java.util.Arrays;
|
10
10
|
import java.util.List;
|
11
11
|
|
12
|
-
import org.apache.poi.ss.usermodel.
|
12
|
+
import org.apache.poi.ss.usermodel.BorderStyle;
|
13
13
|
import org.embulk.parser.EmbulkPluginTester;
|
14
14
|
import org.embulk.parser.EmbulkTestOutputPlugin.OutputRecord;
|
15
15
|
import org.embulk.parser.EmbulkTestParserConfig;
|
@@ -44,11 +44,11 @@ public class TestPoiExcelParserPlugin_cellStyle {
|
|
44
44
|
List<OutputRecord> result = tester.runParser(inFile, parser);
|
45
45
|
|
46
46
|
assertThat(result.size(), is(5));
|
47
|
-
check1(result, 0, "red", 255, 0, 0, "top",
|
47
|
+
check1(result, 0, "red", 255, 0, 0, "top", BorderStyle.THIN.getCode(), 0, 0, 0);
|
48
48
|
check1(result, 1, "green", 0, 128, 0, null, 0, 0, 0, 0);
|
49
|
-
check1(result, 2, "blue", 0, 0, 255, "left", 0, 0,
|
50
|
-
check1(result, 3, "white", 255, 255, 255, "right", 0, 0, 0,
|
51
|
-
check1(result, 4, "black", 0, 0, 0, "bottom", 0,
|
49
|
+
check1(result, 2, "blue", 0, 0, 255, "left", 0, 0, BorderStyle.THIN.getCode(), 0);
|
50
|
+
check1(result, 3, "white", 255, 255, 255, "right", 0, 0, 0, BorderStyle.THIN.getCode());
|
51
|
+
check1(result, 4, "black", 0, 0, 0, "bottom", 0, BorderStyle.MEDIUM.getCode(), 0, 0);
|
52
52
|
}
|
53
53
|
}
|
54
54
|
|
@@ -81,11 +81,11 @@ public class TestPoiExcelParserPlugin_cellStyle {
|
|
81
81
|
List<OutputRecord> result = tester.runParser(inFile, parser);
|
82
82
|
|
83
83
|
assertThat(result.size(), is(5));
|
84
|
-
check2(result, 0, "red", 255, 0, 0, "top",
|
84
|
+
check2(result, 0, "red", 255, 0, 0, "top", BorderStyle.THIN.getCode(), 0, 0, 0);
|
85
85
|
check2(result, 1, "green", 0, 128, 0, null, 0, 0, 0, 0);
|
86
|
-
check2(result, 2, "blue", 0, 0, 255, "left", 0, 0,
|
87
|
-
check2(result, 3, "white", 255, 255, 255, "right", 0, 0, 0,
|
88
|
-
check2(result, 4, "black", 0, 0, 0, "bottom", 0,
|
86
|
+
check2(result, 2, "blue", 0, 0, 255, "left", 0, 0, BorderStyle.THIN.getCode(), 0);
|
87
|
+
check2(result, 3, "white", 255, 255, 255, "right", 0, 0, 0, BorderStyle.THIN.getCode());
|
88
|
+
check2(result, 4, "black", 0, 0, 0, "bottom", 0, BorderStyle.MEDIUM.getCode(), 0, 0);
|
89
89
|
}
|
90
90
|
}
|
91
91
|
|
@@ -130,11 +130,11 @@ public class TestPoiExcelParserPlugin_cellStyle {
|
|
130
130
|
List<OutputRecord> result = tester.runParser(inFile, parser);
|
131
131
|
|
132
132
|
assertThat(result.size(), is(5));
|
133
|
-
check2(result, 0, "red", 255, 0, 0, "top",
|
133
|
+
check2(result, 0, "red", 255, 0, 0, "top", BorderStyle.THIN.getCode(), 0, 0, 0);
|
134
134
|
check2(result, 1, "green", 0, 128, 0, null, 0, 0, 0, 0);
|
135
|
-
check2(result, 2, "blue", 0, 0, 255, "left", 0, 0,
|
136
|
-
check2(result, 3, "white", 255, 255, 255, "right", 0, 0, 0,
|
137
|
-
check2(result, 4, "black", 0, 0, 0, "bottom", 0,
|
135
|
+
check2(result, 2, "blue", 0, 0, 255, "left", 0, 0, BorderStyle.THIN.getCode(), 0);
|
136
|
+
check2(result, 3, "white", 255, 255, 255, "right", 0, 0, 0, BorderStyle.THIN.getCode());
|
137
|
+
check2(result, 4, "black", 0, 0, 0, "bottom", 0, BorderStyle.MEDIUM.getCode(), 0, 0);
|
138
138
|
}
|
139
139
|
}
|
140
140
|
}
|