embulk-parser-poi_excel 0.1.10 → 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 +1 -1
- data/build.gradle +6 -10
- 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/bean/PoiExcelColumnBean.java +12 -5
- 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/PoiExcelCellValueVisitor.java +3 -33
- 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 +8 -4
- 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_mergedCell.java +5 -0
- metadata +7 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3ac332670f656bcf9bbf5fe659b53a9a5d61ed34
|
4
|
+
data.tar.gz: b08187d453742b61242f3c0a414b859e7b3df605
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d10568439d7728ce805c8a4945dce146b3c5b3983b1be2433b13986a07be0ac0cb52763daebe5c2cc0e0154403e3ec3a3fbbc57e1ff6112afb01a23157ad11da
|
7
|
+
data.tar.gz: e3b6f6efa059db9b8994ae78700cc8c50f67d80059b76eb41dafbc1b5ce26f1b133c1def929a7e4aa1d1f0fdaaff0d174683d2dba86956948276d2038275dd2e
|
data/README.md
CHANGED
@@ -52,7 +52,7 @@ if omit **column_number** when **value** is `cell_value`, specified next column.
|
|
52
52
|
* **on_evaluate_error**: processing method of evaluate formula error. see below. (string, default: `exception`)
|
53
53
|
* **formula_replace**: replace formula before evaluate. see below.
|
54
54
|
* **on_convert_error**: processing method of convert error. see below. (string, default: `exception`)
|
55
|
-
* **search_merged_cell**: search merged cell when cell is BLANK.
|
55
|
+
* **search_merged_cell**: search merged cell when cell is BLANK. (`none`, `linear_search`, `tree_search` or `hash_search`, default: `hash_search`)
|
56
56
|
|
57
57
|
### value
|
58
58
|
|
data/build.gradle
CHANGED
@@ -13,7 +13,7 @@ configurations {
|
|
13
13
|
provided
|
14
14
|
}
|
15
15
|
|
16
|
-
version = "0.1.
|
16
|
+
version = "0.1.11"
|
17
17
|
|
18
18
|
sourceCompatibility = 1.7
|
19
19
|
targetCompatibility = 1.7
|
@@ -50,15 +50,11 @@ task gemPush(type: JRubyExec, dependsOn: ["gem"]) {
|
|
50
50
|
scriptArgs "push", "pkg/${project.name}-${project.version}.gem"
|
51
51
|
}
|
52
52
|
|
53
|
-
task
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
}
|
58
|
-
|
59
|
-
task "package"(dependsOn: ["gemspec", "classpath"]) << {
|
60
|
-
println "> Build succeeded."
|
61
|
-
println "> You can run embulk with '-L ${file(".").absolutePath}' argument."
|
53
|
+
task "package"(dependsOn: ["gemspec", "classpath"]) {
|
54
|
+
doLast {
|
55
|
+
println "> Build succeeded."
|
56
|
+
println "> You can run embulk with '-L ${file(".").absolutePath}' argument."
|
57
|
+
}
|
62
58
|
}
|
63
59
|
|
64
60
|
task gemspec {
|
Binary file
|
@@ -1,6 +1,5 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-bin.zip
|
1
|
+
distributionBase=GRADLE_USER_HOME
|
2
|
+
distributionPath=wrapper/dists
|
3
|
+
zipStoreBase=GRADLE_USER_HOME
|
4
|
+
zipStorePath=wrapper/dists
|
5
|
+
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-bin.zip
|
data/gradlew
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
#!/usr/bin/env
|
1
|
+
#!/usr/bin/env sh
|
2
2
|
|
3
3
|
##############################################################################
|
4
4
|
##
|
@@ -6,20 +6,38 @@
|
|
6
6
|
##
|
7
7
|
##############################################################################
|
8
8
|
|
9
|
-
#
|
10
|
-
|
9
|
+
# Attempt to set APP_HOME
|
10
|
+
# Resolve links: $0 may be a link
|
11
|
+
PRG="$0"
|
12
|
+
# Need this for relative symlinks.
|
13
|
+
while [ -h "$PRG" ] ; do
|
14
|
+
ls=`ls -ld "$PRG"`
|
15
|
+
link=`expr "$ls" : '.*-> \(.*\)$'`
|
16
|
+
if expr "$link" : '/.*' > /dev/null; then
|
17
|
+
PRG="$link"
|
18
|
+
else
|
19
|
+
PRG=`dirname "$PRG"`"/$link"
|
20
|
+
fi
|
21
|
+
done
|
22
|
+
SAVED="`pwd`"
|
23
|
+
cd "`dirname \"$PRG\"`/" >/dev/null
|
24
|
+
APP_HOME="`pwd -P`"
|
25
|
+
cd "$SAVED" >/dev/null
|
11
26
|
|
12
27
|
APP_NAME="Gradle"
|
13
28
|
APP_BASE_NAME=`basename "$0"`
|
14
29
|
|
30
|
+
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
31
|
+
DEFAULT_JVM_OPTS=""
|
32
|
+
|
15
33
|
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
16
34
|
MAX_FD="maximum"
|
17
35
|
|
18
|
-
warn (
|
36
|
+
warn () {
|
19
37
|
echo "$*"
|
20
38
|
}
|
21
39
|
|
22
|
-
die (
|
40
|
+
die () {
|
23
41
|
echo
|
24
42
|
echo "$*"
|
25
43
|
echo
|
@@ -30,6 +48,7 @@ die ( ) {
|
|
30
48
|
cygwin=false
|
31
49
|
msys=false
|
32
50
|
darwin=false
|
51
|
+
nonstop=false
|
33
52
|
case "`uname`" in
|
34
53
|
CYGWIN* )
|
35
54
|
cygwin=true
|
@@ -40,31 +59,11 @@ case "`uname`" in
|
|
40
59
|
MINGW* )
|
41
60
|
msys=true
|
42
61
|
;;
|
62
|
+
NONSTOP* )
|
63
|
+
nonstop=true
|
64
|
+
;;
|
43
65
|
esac
|
44
66
|
|
45
|
-
# For Cygwin, ensure paths are in UNIX format before anything is touched.
|
46
|
-
if $cygwin ; then
|
47
|
-
[ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
|
48
|
-
fi
|
49
|
-
|
50
|
-
# Attempt to set APP_HOME
|
51
|
-
# Resolve links: $0 may be a link
|
52
|
-
PRG="$0"
|
53
|
-
# Need this for relative symlinks.
|
54
|
-
while [ -h "$PRG" ] ; do
|
55
|
-
ls=`ls -ld "$PRG"`
|
56
|
-
link=`expr "$ls" : '.*-> \(.*\)$'`
|
57
|
-
if expr "$link" : '/.*' > /dev/null; then
|
58
|
-
PRG="$link"
|
59
|
-
else
|
60
|
-
PRG=`dirname "$PRG"`"/$link"
|
61
|
-
fi
|
62
|
-
done
|
63
|
-
SAVED="`pwd`"
|
64
|
-
cd "`dirname \"$PRG\"`/" >&-
|
65
|
-
APP_HOME="`pwd -P`"
|
66
|
-
cd "$SAVED" >&-
|
67
|
-
|
68
67
|
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
69
68
|
|
70
69
|
# Determine the Java command to use to start the JVM.
|
@@ -90,7 +89,7 @@ location of your Java installation."
|
|
90
89
|
fi
|
91
90
|
|
92
91
|
# Increase the maximum file descriptors if we can.
|
93
|
-
if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
|
92
|
+
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
|
94
93
|
MAX_FD_LIMIT=`ulimit -H -n`
|
95
94
|
if [ $? -eq 0 ] ; then
|
96
95
|
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
@@ -114,6 +113,7 @@ fi
|
|
114
113
|
if $cygwin ; then
|
115
114
|
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
116
115
|
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
116
|
+
JAVACMD=`cygpath --unix "$JAVACMD"`
|
117
117
|
|
118
118
|
# We build the pattern for arguments to be converted via cygpath
|
119
119
|
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
@@ -154,11 +154,19 @@ if $cygwin ; then
|
|
154
154
|
esac
|
155
155
|
fi
|
156
156
|
|
157
|
-
#
|
158
|
-
|
159
|
-
|
157
|
+
# Escape application args
|
158
|
+
save () {
|
159
|
+
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
160
|
+
echo " "
|
160
161
|
}
|
161
|
-
|
162
|
-
|
162
|
+
APP_ARGS=$(save "$@")
|
163
|
+
|
164
|
+
# Collect all arguments for the java command, following the shell quoting and substitution rules
|
165
|
+
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
|
166
|
+
|
167
|
+
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
|
168
|
+
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
|
169
|
+
cd "$(dirname "$0")"
|
170
|
+
fi
|
163
171
|
|
164
|
-
exec "$JAVACMD" "
|
172
|
+
exec "$JAVACMD" "$@"
|
data/gradlew.bat
CHANGED
@@ -8,14 +8,14 @@
|
|
8
8
|
@rem Set local scope for the variables with windows NT shell
|
9
9
|
if "%OS%"=="Windows_NT" setlocal
|
10
10
|
|
11
|
-
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
12
|
-
set DEFAULT_JVM_OPTS=
|
13
|
-
|
14
11
|
set DIRNAME=%~dp0
|
15
12
|
if "%DIRNAME%" == "" set DIRNAME=.
|
16
13
|
set APP_BASE_NAME=%~n0
|
17
14
|
set APP_HOME=%DIRNAME%
|
18
15
|
|
16
|
+
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
17
|
+
set DEFAULT_JVM_OPTS=
|
18
|
+
|
19
19
|
@rem Find java.exe
|
20
20
|
if defined JAVA_HOME goto findJavaFromJavaHome
|
21
21
|
|
@@ -46,10 +46,9 @@ echo location of your Java installation.
|
|
46
46
|
goto fail
|
47
47
|
|
48
48
|
:init
|
49
|
-
@rem Get command-line arguments, handling
|
49
|
+
@rem Get command-line arguments, handling Windows variants
|
50
50
|
|
51
51
|
if not "%OS%" == "Windows_NT" goto win9xME_args
|
52
|
-
if "%@eval[2+2]" == "4" goto 4NT_args
|
53
52
|
|
54
53
|
:win9xME_args
|
55
54
|
@rem Slurp the command line arguments.
|
@@ -60,11 +59,6 @@ set _SKIP=2
|
|
60
59
|
if "x%~1" == "x" goto execute
|
61
60
|
|
62
61
|
set CMD_LINE_ARGS=%*
|
63
|
-
goto execute
|
64
|
-
|
65
|
-
:4NT_args
|
66
|
-
@rem Get arguments from the 4NT Shell from JP Software
|
67
|
-
set CMD_LINE_ARGS=%$
|
68
62
|
|
69
63
|
:execute
|
70
64
|
@rem Setup the command line
|
@@ -12,6 +12,8 @@ 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
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;
|
15
17
|
import org.embulk.spi.Column;
|
16
18
|
|
17
19
|
import com.google.common.base.Optional;
|
@@ -268,10 +270,6 @@ public class PoiExcelColumnBean {
|
|
268
270
|
return numericFormat.get();
|
269
271
|
}
|
270
272
|
|
271
|
-
public enum SearchMergedCell {
|
272
|
-
NONE, LINEAR_SEARCH, TREE_SEARCH
|
273
|
-
}
|
274
|
-
|
275
273
|
private CacheValue<SearchMergedCell> searchMergedCell = new CacheValue<SearchMergedCell>() {
|
276
274
|
|
277
275
|
@Override
|
@@ -302,7 +300,7 @@ public class PoiExcelColumnBean {
|
|
302
300
|
|
303
301
|
@Override
|
304
302
|
protected SearchMergedCell getDefaultValue() {
|
305
|
-
return SearchMergedCell.
|
303
|
+
return SearchMergedCell.HASH_SEARCH;
|
306
304
|
}
|
307
305
|
};
|
308
306
|
|
@@ -310,6 +308,15 @@ public class PoiExcelColumnBean {
|
|
310
308
|
return searchMergedCell.get();
|
311
309
|
}
|
312
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
|
+
|
313
320
|
public enum FormulaHandling {
|
314
321
|
EVALUATE, CASHED_VALUE
|
315
322
|
}
|
@@ -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
|
+
}
|
@@ -18,9 +18,8 @@ import org.embulk.parser.poi_excel.PoiExcelParserPlugin.FormulaReplaceTask;
|
|
18
18
|
import org.embulk.parser.poi_excel.bean.PoiExcelColumnBean;
|
19
19
|
import org.embulk.parser.poi_excel.bean.PoiExcelColumnBean.ErrorStrategy;
|
20
20
|
import org.embulk.parser.poi_excel.bean.PoiExcelColumnBean.FormulaHandling;
|
21
|
-
import org.embulk.parser.poi_excel.bean.PoiExcelColumnBean.SearchMergedCell;
|
22
21
|
import org.embulk.parser.poi_excel.visitor.embulk.CellVisitor;
|
23
|
-
import org.embulk.parser.poi_excel.visitor.util.
|
22
|
+
import org.embulk.parser.poi_excel.visitor.util.MergedRegionFinder;
|
24
23
|
import org.embulk.spi.Column;
|
25
24
|
import org.embulk.spi.Exec;
|
26
25
|
import org.embulk.spi.PageBuilder;
|
@@ -100,41 +99,12 @@ public class PoiExcelCellValueVisitor {
|
|
100
99
|
}
|
101
100
|
|
102
101
|
protected CellRangeAddress findRegion(PoiExcelColumnBean bean, Cell cell) {
|
103
|
-
SearchMergedCell search = bean.getSearchMergedCell();
|
104
|
-
switch (search) {
|
105
|
-
case NONE:
|
106
|
-
return null;
|
107
|
-
case LINEAR_SEARCH:
|
108
|
-
return findRegionLinearSearch(bean, cell);
|
109
|
-
default:
|
110
|
-
return findRegionTreeSearch(bean, cell);
|
111
|
-
}
|
112
|
-
}
|
113
|
-
|
114
|
-
protected CellRangeAddress findRegionLinearSearch(PoiExcelColumnBean bean, Cell cell) {
|
115
|
-
Sheet sheet = cell.getSheet();
|
116
|
-
int r = cell.getRowIndex();
|
117
|
-
int c = cell.getColumnIndex();
|
118
|
-
|
119
|
-
int size = sheet.getNumMergedRegions();
|
120
|
-
for (int i = 0; i < size; i++) {
|
121
|
-
CellRangeAddress region = sheet.getMergedRegion(i);
|
122
|
-
if (region.isInRange(r, c)) {
|
123
|
-
return region;
|
124
|
-
}
|
125
|
-
}
|
126
|
-
|
127
|
-
return null;
|
128
|
-
}
|
129
|
-
|
130
|
-
private final MergedRegionMap mergedRegionMap = new MergedRegionMap();
|
131
|
-
|
132
|
-
protected CellRangeAddress findRegionTreeSearch(PoiExcelColumnBean bean, Cell cell) {
|
133
102
|
Sheet sheet = cell.getSheet();
|
134
103
|
int r = cell.getRowIndex();
|
135
104
|
int c = cell.getColumnIndex();
|
136
105
|
|
137
|
-
|
106
|
+
MergedRegionFinder finder = bean.getMergedRegionFinder();
|
107
|
+
return finder.get(sheet, r, c);
|
138
108
|
}
|
139
109
|
|
140
110
|
protected void visitCellValueFormula(PoiExcelColumnBean bean, Cell cell, CellVisitor visitor) {
|
@@ -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
|
+
}
|
@@ -1,16 +1,16 @@
|
|
1
1
|
package org.embulk.parser.poi_excel.visitor.util;
|
2
2
|
|
3
3
|
import java.util.Map;
|
4
|
-
import java.util.TreeMap;
|
5
4
|
import java.util.concurrent.ConcurrentHashMap;
|
6
5
|
|
7
6
|
import org.apache.poi.ss.usermodel.Sheet;
|
8
7
|
import org.apache.poi.ss.util.CellRangeAddress;
|
9
8
|
|
10
|
-
public class MergedRegionMap {
|
9
|
+
public abstract class MergedRegionMap implements MergedRegionFinder {
|
11
10
|
|
12
11
|
private final Map<Sheet, Map<Integer, Map<Integer, CellRangeAddress>>> sheetMap = new ConcurrentHashMap<>();
|
13
12
|
|
13
|
+
@Override
|
14
14
|
public CellRangeAddress get(Sheet sheet, int rowIndex, int columnIndex) {
|
15
15
|
Map<Integer, Map<Integer, CellRangeAddress>> rowMap = sheetMap.get(sheet);
|
16
16
|
if (rowMap == null) {
|
@@ -28,7 +28,7 @@ public class MergedRegionMap {
|
|
28
28
|
}
|
29
29
|
|
30
30
|
protected Map<Integer, Map<Integer, CellRangeAddress>> createRowMap(Sheet sheet) {
|
31
|
-
Map<Integer, Map<Integer, CellRangeAddress>> rowMap =
|
31
|
+
Map<Integer, Map<Integer, CellRangeAddress>> rowMap = newRowMap();
|
32
32
|
|
33
33
|
for (int i = sheet.getNumMergedRegions() - 1; i >= 0; i--) {
|
34
34
|
CellRangeAddress region = sheet.getMergedRegion(i);
|
@@ -36,7 +36,7 @@ public class MergedRegionMap {
|
|
36
36
|
for (int r = region.getFirstRow(); r <= region.getLastRow(); r++) {
|
37
37
|
Map<Integer, CellRangeAddress> columnMap = rowMap.get(r);
|
38
38
|
if (columnMap == null) {
|
39
|
-
columnMap =
|
39
|
+
columnMap = newColumnMap();
|
40
40
|
rowMap.put(r, columnMap);
|
41
41
|
}
|
42
42
|
|
@@ -48,4 +48,8 @@ public class MergedRegionMap {
|
|
48
48
|
|
49
49
|
return rowMap;
|
50
50
|
}
|
51
|
+
|
52
|
+
protected abstract Map<Integer, Map<Integer, CellRangeAddress>> newRowMap();
|
53
|
+
|
54
|
+
protected abstract Map<Integer, CellRangeAddress> newColumnMap();
|
51
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
|
+
}
|
@@ -53,6 +53,11 @@ public class TestPoiExcelParserPlugin_mergedCell {
|
|
53
53
|
test(excelFile, "tree_search", true);
|
54
54
|
}
|
55
55
|
|
56
|
+
@Theory
|
57
|
+
public void testSearchMergedCell_hash(String excelFile) throws ParseException {
|
58
|
+
test(excelFile, "hash_search", true);
|
59
|
+
}
|
60
|
+
|
56
61
|
private void test(String excelFile, Object arg, boolean search) {
|
57
62
|
try (EmbulkPluginTester tester = new EmbulkPluginTester()) {
|
58
63
|
tester.addParserPlugin(PoiExcelParserPlugin.TYPE, PoiExcelParserPlugin.class);
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: embulk-parser-poi_excel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- hishidama
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-09-
|
11
|
+
date: 2020-09-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
@@ -52,7 +52,7 @@ files:
|
|
52
52
|
- classpath/commons-codec-1.10.jar
|
53
53
|
- classpath/commons-collections4-4.1.jar
|
54
54
|
- classpath/curvesapi-1.04.jar
|
55
|
-
- classpath/embulk-parser-poi_excel-0.1.
|
55
|
+
- classpath/embulk-parser-poi_excel-0.1.11.jar
|
56
56
|
- classpath/embulk-standards-0.7.5.jar
|
57
57
|
- classpath/poi-3.17.jar
|
58
58
|
- classpath/poi-ooxml-3.17.jar
|
@@ -70,6 +70,7 @@ files:
|
|
70
70
|
- src/main/java/org/embulk/parser/poi_excel/bean/PoiExcelColumnIndex.java
|
71
71
|
- src/main/java/org/embulk/parser/poi_excel/bean/PoiExcelSheetBean.java
|
72
72
|
- src/main/java/org/embulk/parser/poi_excel/bean/util/PoiExcelCellAddress.java
|
73
|
+
- src/main/java/org/embulk/parser/poi_excel/bean/util/SearchMergedCell.java
|
73
74
|
- src/main/java/org/embulk/parser/poi_excel/visitor/AbstractPoiExcelCellAttributeVisitor.java
|
74
75
|
- src/main/java/org/embulk/parser/poi_excel/visitor/PoiExcelCellCommentVisitor.java
|
75
76
|
- src/main/java/org/embulk/parser/poi_excel/visitor/PoiExcelCellFontVisitor.java
|
@@ -87,7 +88,10 @@ files:
|
|
87
88
|
- src/main/java/org/embulk/parser/poi_excel/visitor/embulk/LongCellVisitor.java
|
88
89
|
- src/main/java/org/embulk/parser/poi_excel/visitor/embulk/StringCellVisitor.java
|
89
90
|
- src/main/java/org/embulk/parser/poi_excel/visitor/embulk/TimestampCellVisitor.java
|
91
|
+
- src/main/java/org/embulk/parser/poi_excel/visitor/util/MergedRegionFinder.java
|
92
|
+
- src/main/java/org/embulk/parser/poi_excel/visitor/util/MergedRegionList.java
|
90
93
|
- src/main/java/org/embulk/parser/poi_excel/visitor/util/MergedRegionMap.java
|
94
|
+
- src/main/java/org/embulk/parser/poi_excel/visitor/util/MergedRegionNothing.java
|
91
95
|
- src/test/java/org/embulk/parser/EmbulkPluginTester.java
|
92
96
|
- src/test/java/org/embulk/parser/EmbulkTestFileInputPlugin.java
|
93
97
|
- src/test/java/org/embulk/parser/EmbulkTestOutputPlugin.java
|