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.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +52 -5
  3. data/build.gradle +17 -11
  4. data/gradle/wrapper/gradle-wrapper.jar +0 -0
  5. data/gradle/wrapper/gradle-wrapper.properties +5 -6
  6. data/gradlew +43 -35
  7. data/gradlew.bat +4 -10
  8. data/src/main/java/org/embulk/parser/poi_excel/PoiExcelColumnValueType.java +4 -0
  9. data/src/main/java/org/embulk/parser/poi_excel/PoiExcelParserPlugin.java +80 -3
  10. data/src/main/java/org/embulk/parser/poi_excel/bean/PoiExcelColumnBean.java +110 -6
  11. data/src/main/java/org/embulk/parser/poi_excel/bean/PoiExcelColumnIndex.java +74 -37
  12. data/src/main/java/org/embulk/parser/poi_excel/bean/util/PoiExcelCellAddress.java +50 -0
  13. data/src/main/java/org/embulk/parser/poi_excel/bean/util/SearchMergedCell.java +71 -0
  14. data/src/main/java/org/embulk/parser/poi_excel/visitor/PoiExcelCellFontVisitor.java +0 -6
  15. data/src/main/java/org/embulk/parser/poi_excel/visitor/PoiExcelCellStyleVisitor.java +11 -11
  16. data/src/main/java/org/embulk/parser/poi_excel/visitor/PoiExcelCellTypeVisitor.java +52 -0
  17. data/src/main/java/org/embulk/parser/poi_excel/visitor/PoiExcelCellValueVisitor.java +79 -40
  18. data/src/main/java/org/embulk/parser/poi_excel/visitor/PoiExcelClientAnchorVisitor.java +1 -1
  19. data/src/main/java/org/embulk/parser/poi_excel/visitor/PoiExcelColumnVisitor.java +64 -4
  20. data/src/main/java/org/embulk/parser/poi_excel/visitor/PoiExcelVisitorFactory.java +14 -0
  21. data/src/main/java/org/embulk/parser/poi_excel/visitor/embulk/BooleanCellVisitor.java +5 -0
  22. data/src/main/java/org/embulk/parser/poi_excel/visitor/embulk/CellVisitor.java +3 -0
  23. data/src/main/java/org/embulk/parser/poi_excel/visitor/embulk/DoubleCellVisitor.java +5 -0
  24. data/src/main/java/org/embulk/parser/poi_excel/visitor/embulk/LongCellVisitor.java +5 -0
  25. data/src/main/java/org/embulk/parser/poi_excel/visitor/embulk/StringCellVisitor.java +30 -2
  26. data/src/main/java/org/embulk/parser/poi_excel/visitor/embulk/TimestampCellVisitor.java +5 -0
  27. data/src/main/java/org/embulk/parser/poi_excel/visitor/util/MergedRegionFinder.java +9 -0
  28. data/src/main/java/org/embulk/parser/poi_excel/visitor/util/MergedRegionList.java +20 -0
  29. data/src/main/java/org/embulk/parser/poi_excel/visitor/util/MergedRegionMap.java +55 -0
  30. data/src/main/java/org/embulk/parser/poi_excel/visitor/util/MergedRegionNothing.java +12 -0
  31. data/src/test/java/org/embulk/parser/poi_excel/TestPoiExcelParserPlugin.java +27 -79
  32. data/src/test/java/org/embulk/parser/poi_excel/TestPoiExcelParserPlugin_cellAddress.java +69 -0
  33. data/src/test/java/org/embulk/parser/poi_excel/TestPoiExcelParserPlugin_cellComment.java +1 -1
  34. data/src/test/java/org/embulk/parser/poi_excel/TestPoiExcelParserPlugin_cellError.java +1 -1
  35. data/src/test/java/org/embulk/parser/poi_excel/TestPoiExcelParserPlugin_cellFont.java +1 -1
  36. data/src/test/java/org/embulk/parser/poi_excel/TestPoiExcelParserPlugin_cellStyle.java +14 -14
  37. data/src/test/java/org/embulk/parser/poi_excel/TestPoiExcelParserPlugin_cellType.java +79 -0
  38. data/src/test/java/org/embulk/parser/poi_excel/TestPoiExcelParserPlugin_columnNumber.java +1 -1
  39. data/src/test/java/org/embulk/parser/poi_excel/TestPoiExcelParserPlugin_constant.java +1 -1
  40. data/src/test/java/org/embulk/parser/poi_excel/TestPoiExcelParserPlugin_convertError.java +1 -1
  41. data/src/test/java/org/embulk/parser/poi_excel/TestPoiExcelParserPlugin_formula.java +90 -0
  42. data/src/test/java/org/embulk/parser/poi_excel/TestPoiExcelParserPlugin_mergedCell.java +94 -0
  43. data/src/test/java/org/embulk/parser/poi_excel/TestPoiExcelParserPlugin_sheets.java +35 -1
  44. metadata +30 -18
@@ -0,0 +1,52 @@
1
+ package org.embulk.parser.poi_excel.visitor;
2
+
3
+ import org.apache.poi.ss.usermodel.Cell;
4
+ import org.apache.poi.ss.usermodel.CellType;
5
+ import org.embulk.parser.poi_excel.bean.PoiExcelColumnBean;
6
+ import org.embulk.parser.poi_excel.visitor.embulk.CellVisitor;
7
+ import org.embulk.spi.Column;
8
+ import org.embulk.spi.PageBuilder;
9
+ import org.embulk.spi.type.StringType;
10
+
11
+ public class PoiExcelCellTypeVisitor {
12
+ protected final PoiExcelVisitorValue visitorValue;
13
+ protected final PageBuilder pageBuilder;
14
+
15
+ public PoiExcelCellTypeVisitor(PoiExcelVisitorValue visitorValue) {
16
+ this.visitorValue = visitorValue;
17
+ this.pageBuilder = visitorValue.getPageBuilder();
18
+ }
19
+
20
+ public void visit(PoiExcelColumnBean bean, Cell cell, CellType cellType, CellVisitor visitor) {
21
+ assert cell != null;
22
+
23
+ Column column = bean.getColumn();
24
+ if (column.getType() instanceof StringType) {
25
+ String type = cellType.name();
26
+ visitor.visitCellValueString(column, cell, type);
27
+ return;
28
+ }
29
+
30
+ int code = getCode(cellType);
31
+ visitor.visitCellValueNumeric(column, cell, code);
32
+ }
33
+
34
+ private static int getCode(CellType cellType) {
35
+ switch (cellType) {
36
+ case NUMERIC:
37
+ return 0;
38
+ case STRING:
39
+ return 1;
40
+ case FORMULA:
41
+ return 2;
42
+ case BLANK:
43
+ return 3;
44
+ case BOOLEAN:
45
+ return 4;
46
+ case ERROR:
47
+ return 5;
48
+ default:
49
+ return -1;
50
+ }
51
+ }
52
+ }
@@ -4,6 +4,7 @@ import java.text.MessageFormat;
4
4
  import java.util.List;
5
5
 
6
6
  import org.apache.poi.ss.usermodel.Cell;
7
+ import org.apache.poi.ss.usermodel.CellType;
7
8
  import org.apache.poi.ss.usermodel.CellValue;
8
9
  import org.apache.poi.ss.usermodel.CreationHelper;
9
10
  import org.apache.poi.ss.usermodel.FormulaError;
@@ -16,7 +17,9 @@ import org.embulk.parser.poi_excel.PoiExcelColumnValueType;
16
17
  import org.embulk.parser.poi_excel.PoiExcelParserPlugin.FormulaReplaceTask;
17
18
  import org.embulk.parser.poi_excel.bean.PoiExcelColumnBean;
18
19
  import org.embulk.parser.poi_excel.bean.PoiExcelColumnBean.ErrorStrategy;
20
+ import org.embulk.parser.poi_excel.bean.PoiExcelColumnBean.FormulaHandling;
19
21
  import org.embulk.parser.poi_excel.visitor.embulk.CellVisitor;
22
+ import org.embulk.parser.poi_excel.visitor.util.MergedRegionFinder;
20
23
  import org.embulk.spi.Column;
21
24
  import org.embulk.spi.Exec;
22
25
  import org.embulk.spi.PageBuilder;
@@ -38,15 +41,15 @@ public class PoiExcelCellValueVisitor {
38
41
 
39
42
  Column column = bean.getColumn();
40
43
 
41
- int cellType = cell.getCellType();
44
+ CellType cellType = cell.getCellTypeEnum();
42
45
  switch (cellType) {
43
- case Cell.CELL_TYPE_NUMERIC:
46
+ case NUMERIC:
44
47
  visitor.visitCellValueNumeric(column, cell, cell.getNumericCellValue());
45
48
  return;
46
- case Cell.CELL_TYPE_STRING:
49
+ case STRING:
47
50
  visitor.visitCellValueString(column, cell, cell.getStringCellValue());
48
51
  return;
49
- case Cell.CELL_TYPE_FORMULA:
52
+ case FORMULA:
50
53
  PoiExcelColumnValueType valueType = bean.getValueType();
51
54
  if (valueType == PoiExcelColumnValueType.CELL_FORMULA) {
52
55
  visitor.visitCellFormula(column, cell);
@@ -54,13 +57,13 @@ public class PoiExcelCellValueVisitor {
54
57
  visitCellValueFormula(bean, cell, visitor);
55
58
  }
56
59
  return;
57
- case Cell.CELL_TYPE_BLANK:
60
+ case BLANK:
58
61
  visitCellValueBlank(bean, cell, visitor);
59
62
  return;
60
- case Cell.CELL_TYPE_BOOLEAN:
63
+ case BOOLEAN:
61
64
  visitor.visitCellValueBoolean(column, cell, cell.getBooleanCellValue());
62
65
  return;
63
- case Cell.CELL_TYPE_ERROR:
66
+ case ERROR:
64
67
  visitCellValueError(bean, cell, cell.getErrorCellValue(), visitor);
65
68
  return;
66
69
  default:
@@ -69,35 +72,24 @@ public class PoiExcelCellValueVisitor {
69
72
  }
70
73
 
71
74
  protected void visitCellValueBlank(PoiExcelColumnBean bean, Cell cell, CellVisitor visitor) {
72
- assert cell.getCellType() == Cell.CELL_TYPE_BLANK;
75
+ assert cell.getCellTypeEnum() == CellType.BLANK;
73
76
 
74
77
  Column column = bean.getColumn();
75
78
 
76
- boolean search = bean.getSearchMergedCell();
77
- if (!search) {
78
- visitor.visitCellValueBlank(column, cell);
79
- return;
80
- }
81
-
82
- int r = cell.getRowIndex();
83
- int c = cell.getColumnIndex();
84
-
85
- Sheet sheet = cell.getSheet();
86
- int size = sheet.getNumMergedRegions();
87
- for (int i = 0; i < size; i++) {
88
- CellRangeAddress range = visitorValue.getSheet().getMergedRegion(i);
89
- if (range.isInRange(r, c)) {
90
- Row firstRow = sheet.getRow(range.getFirstRow());
91
- if (firstRow == null) {
92
- visitCellNull(column);
93
- return;
94
- }
95
- Cell firstCell = firstRow.getCell(range.getFirstColumn());
96
- if (firstCell == null) {
97
- visitCellNull(column);
98
- return;
99
- }
79
+ CellRangeAddress region = findRegion(bean, cell);
80
+ if (region != null) {
81
+ Row firstRow = cell.getSheet().getRow(region.getFirstRow());
82
+ if (firstRow == null) {
83
+ visitCellNull(column);
84
+ return;
85
+ }
86
+ Cell firstCell = firstRow.getCell(region.getFirstColumn());
87
+ if (firstCell == null) {
88
+ visitCellNull(column);
89
+ return;
90
+ }
100
91
 
92
+ if (firstCell.getRowIndex() != cell.getRowIndex() || firstCell.getColumnIndex() != cell.getColumnIndex()) {
101
93
  visitCellValue(bean, firstCell, visitor);
102
94
  return;
103
95
  }
@@ -106,9 +98,56 @@ public class PoiExcelCellValueVisitor {
106
98
  visitor.visitCellValueBlank(column, cell);
107
99
  }
108
100
 
101
+ protected CellRangeAddress findRegion(PoiExcelColumnBean bean, Cell cell) {
102
+ Sheet sheet = cell.getSheet();
103
+ int r = cell.getRowIndex();
104
+ int c = cell.getColumnIndex();
105
+
106
+ MergedRegionFinder finder = bean.getMergedRegionFinder();
107
+ return finder.get(sheet, r, c);
108
+ }
109
+
109
110
  protected void visitCellValueFormula(PoiExcelColumnBean bean, Cell cell, CellVisitor visitor) {
110
- assert cell.getCellType() == Cell.CELL_TYPE_FORMULA;
111
+ assert cell.getCellTypeEnum() == CellType.FORMULA;
112
+
113
+ FormulaHandling handling = bean.getFormulaHandling();
114
+ switch (handling) {
115
+ case CASHED_VALUE:
116
+ visitCellValueFormulaCashedValue(bean, cell, visitor);
117
+ break;
118
+ default:
119
+ visitCellValueFormulaEvaluate(bean, cell, visitor);
120
+ break;
121
+ }
122
+ }
123
+
124
+ protected void visitCellValueFormulaCashedValue(PoiExcelColumnBean bean, Cell cell, CellVisitor visitor) {
125
+ Column column = bean.getColumn();
126
+
127
+ CellType cellType = cell.getCachedFormulaResultTypeEnum();
128
+ switch (cellType) {
129
+ case NUMERIC:
130
+ visitor.visitCellValueNumeric(column, cell, cell.getNumericCellValue());
131
+ return;
132
+ case STRING:
133
+ visitor.visitCellValueString(column, cell, cell.getStringCellValue());
134
+ return;
135
+ case BLANK:
136
+ visitCellValueBlank(bean, cell, visitor);
137
+ return;
138
+ case BOOLEAN:
139
+ visitor.visitCellValueBoolean(column, cell, cell.getBooleanCellValue());
140
+ return;
141
+ case ERROR:
142
+ visitCellValueError(bean, cell, cell.getErrorCellValue(), visitor);
143
+ return;
144
+ case FORMULA:
145
+ default:
146
+ throw new IllegalStateException(MessageFormat.format("unsupported POI cellType={0}", cellType));
147
+ }
148
+ }
111
149
 
150
+ protected void visitCellValueFormulaEvaluate(PoiExcelColumnBean bean, Cell cell, CellVisitor visitor) {
112
151
  Column column = bean.getColumn();
113
152
 
114
153
  List<FormulaReplaceTask> list = bean.getFormulaReplace();
@@ -159,24 +198,24 @@ public class PoiExcelCellValueVisitor {
159
198
  throw new RuntimeException(MessageFormat.format("evaluate error. formula={0}", cell.getCellFormula()), e);
160
199
  }
161
200
 
162
- int cellType = cellValue.getCellType();
201
+ CellType cellType = cellValue.getCellTypeEnum();
163
202
  switch (cellType) {
164
- case Cell.CELL_TYPE_NUMERIC:
203
+ case NUMERIC:
165
204
  visitor.visitCellValueNumeric(column, cellValue, cellValue.getNumberValue());
166
205
  return;
167
- case Cell.CELL_TYPE_STRING:
206
+ case STRING:
168
207
  visitor.visitCellValueString(column, cellValue, cellValue.getStringValue());
169
208
  return;
170
- case Cell.CELL_TYPE_BLANK:
209
+ case BLANK:
171
210
  visitor.visitCellValueBlank(column, cellValue);
172
211
  return;
173
- case Cell.CELL_TYPE_BOOLEAN:
212
+ case BOOLEAN:
174
213
  visitor.visitCellValueBoolean(column, cellValue, cellValue.getBooleanValue());
175
214
  return;
176
- case Cell.CELL_TYPE_ERROR:
215
+ case ERROR:
177
216
  visitCellValueError(bean, cellValue, cellValue.getErrorValue(), visitor);
178
217
  return;
179
- case Cell.CELL_TYPE_FORMULA:
218
+ case FORMULA:
180
219
  default:
181
220
  throw new IllegalStateException(MessageFormat.format("unsupported POI cellType={0}", cellType));
182
221
  }
@@ -40,7 +40,7 @@ public class PoiExcelClientAnchorVisitor extends AbstractPoiExcelCellAttributeVi
40
40
  map.put("anchor_type", new AttributeSupplier<ClientAnchor>() {
41
41
  @Override
42
42
  public Object get(Column column, Cell cell, ClientAnchor anchor) {
43
- return (long) anchor.getAnchorType();
43
+ return (long) anchor.getAnchorType().value;
44
44
  }
45
45
  });
46
46
  map.put("col1", new AttributeSupplier<ClientAnchor>() {
@@ -3,16 +3,22 @@ package org.embulk.parser.poi_excel.visitor;
3
3
  import java.text.MessageFormat;
4
4
 
5
5
  import org.apache.poi.ss.usermodel.Cell;
6
+ import org.apache.poi.ss.usermodel.CellType;
6
7
  import org.apache.poi.ss.usermodel.Row;
8
+ import org.apache.poi.ss.usermodel.Sheet;
7
9
  import org.apache.poi.ss.util.CellReference;
8
10
  import org.embulk.parser.poi_excel.PoiExcelColumnValueType;
9
11
  import org.embulk.parser.poi_excel.bean.PoiExcelColumnBean;
12
+ import org.embulk.parser.poi_excel.bean.util.PoiExcelCellAddress;
10
13
  import org.embulk.parser.poi_excel.visitor.embulk.CellVisitor;
11
14
  import org.embulk.spi.Column;
12
15
  import org.embulk.spi.ColumnVisitor;
16
+ import org.embulk.spi.Exec;
13
17
  import org.embulk.spi.PageBuilder;
18
+ import org.slf4j.Logger;
14
19
 
15
20
  public class PoiExcelColumnVisitor implements ColumnVisitor {
21
+ private final Logger log = Exec.getLogger(getClass());
16
22
 
17
23
  protected final PoiExcelVisitorValue visitorValue;
18
24
  protected final PageBuilder pageBuilder;
@@ -56,6 +62,9 @@ public class PoiExcelColumnVisitor implements ColumnVisitor {
56
62
  }
57
63
 
58
64
  protected final void visitCell0(Column column, CellVisitor visitor) {
65
+ if (log.isTraceEnabled()) {
66
+ log.trace("{} start", column);
67
+ }
59
68
  try {
60
69
  visitCell(column, visitor);
61
70
  } catch (Exception e) {
@@ -65,21 +74,52 @@ public class PoiExcelColumnVisitor implements ColumnVisitor {
65
74
  throw new RuntimeException(MessageFormat.format("error at {0} cell={1}!{2}. {3}", column, sheetName, ref,
66
75
  e.getMessage()), e);
67
76
  }
77
+ if (log.isTraceEnabled()) {
78
+ log.trace("{} end", column);
79
+ }
68
80
  }
69
81
 
70
82
  protected void visitCell(Column column, CellVisitor visitor) {
71
83
  PoiExcelColumnBean bean = visitorValue.getColumnBean(column);
72
84
  PoiExcelColumnValueType valueType = bean.getValueType();
85
+ PoiExcelCellAddress cellAddress = bean.getCellAddress();
73
86
 
74
87
  switch (valueType) {
75
88
  case SHEET_NAME:
76
- visitor.visitSheetName(column);
89
+ if (cellAddress != null) {
90
+ Sheet sheet = cellAddress.getSheet(currentRow);
91
+ visitor.visitSheetName(column, sheet);
92
+ } else {
93
+ visitor.visitSheetName(column);
94
+ }
77
95
  return;
78
96
  case ROW_NUMBER:
79
- visitor.visitRowNumber(column, currentRow.getRowNum() + 1);
97
+ int rowIndex;
98
+ if (cellAddress != null) {
99
+ Cell cell = cellAddress.getCell(currentRow);
100
+ if (cell == null) {
101
+ visitCellNull(column);
102
+ return;
103
+ }
104
+ rowIndex = cell.getRowIndex();
105
+ } else {
106
+ rowIndex = currentRow.getRowNum();
107
+ }
108
+ visitor.visitRowNumber(column, rowIndex + 1);
80
109
  return;
81
110
  case COLUMN_NUMBER:
82
- visitor.visitColumnNumber(column, bean.getColumnIndex() + 1);
111
+ int columnIndex;
112
+ if (cellAddress != null) {
113
+ Cell cell = cellAddress.getCell(currentRow);
114
+ if (cell == null) {
115
+ visitCellNull(column);
116
+ return;
117
+ }
118
+ columnIndex = cell.getColumnIndex();
119
+ } else {
120
+ columnIndex = bean.getColumnIndex();
121
+ }
122
+ visitor.visitColumnNumber(column, columnIndex + 1);
83
123
  return;
84
124
  case CONSTANT:
85
125
  visitCellConstant(column, bean.getValueTypeSuffix(), visitor);
@@ -89,7 +129,12 @@ public class PoiExcelColumnVisitor implements ColumnVisitor {
89
129
  }
90
130
 
91
131
  assert valueType.useCell();
92
- Cell cell = currentRow.getCell(bean.getColumnIndex());
132
+ Cell cell;
133
+ if (cellAddress != null) {
134
+ cell = cellAddress.getCell(currentRow);
135
+ } else {
136
+ cell = currentRow.getCell(bean.getColumnIndex());
137
+ }
93
138
  if (cell == null) {
94
139
  visitCellNull(column);
95
140
  return;
@@ -108,6 +153,16 @@ public class PoiExcelColumnVisitor implements ColumnVisitor {
108
153
  case CELL_COMMENT:
109
154
  visitCellComment(bean, cell, visitor);
110
155
  return;
156
+ case CELL_TYPE:
157
+ visitCellType(bean, cell, cell.getCellTypeEnum(), visitor);
158
+ return;
159
+ case CELL_CACHED_TYPE:
160
+ if (cell.getCellTypeEnum() == CellType.FORMULA) {
161
+ visitCellType(bean, cell, cell.getCachedFormulaResultTypeEnum(), visitor);
162
+ } else {
163
+ visitCellType(bean, cell, cell.getCellTypeEnum(), visitor);
164
+ }
165
+ return;
111
166
  default:
112
167
  throw new UnsupportedOperationException(MessageFormat.format("unsupported value_type={0}", valueType));
113
168
  }
@@ -144,4 +199,9 @@ public class PoiExcelColumnVisitor implements ColumnVisitor {
144
199
  PoiExcelCellCommentVisitor delegator = factory.getPoiExcelCellCommentVisitor();
145
200
  delegator.visit(bean, cell, visitor);
146
201
  }
202
+
203
+ private void visitCellType(PoiExcelColumnBean bean, Cell cell, CellType cellType, CellVisitor visitor) {
204
+ PoiExcelCellTypeVisitor delegator = factory.getPoiExcelCellTypeVisitor();
205
+ delegator.visit(bean, cell, cellType, visitor);
206
+ }
147
207
  }
@@ -159,6 +159,20 @@ public class PoiExcelVisitorFactory {
159
159
  return new PoiExcelCellCommentVisitor(visitorValue);
160
160
  }
161
161
 
162
+ // cell type
163
+ private PoiExcelCellTypeVisitor poiExcelCellTypeVisitor;
164
+
165
+ public final PoiExcelCellTypeVisitor getPoiExcelCellTypeVisitor() {
166
+ if (poiExcelCellTypeVisitor == null) {
167
+ poiExcelCellTypeVisitor = newPoiExcelCellTypeVisitor();
168
+ }
169
+ return poiExcelCellTypeVisitor;
170
+ }
171
+
172
+ protected PoiExcelCellTypeVisitor newPoiExcelCellTypeVisitor() {
173
+ return new PoiExcelCellTypeVisitor(visitorValue);
174
+ }
175
+
162
176
  // ClientAnchor
163
177
  private PoiExcelClientAnchorVisitor poiExcelClientAnchorVisitor;
164
178
 
@@ -38,6 +38,11 @@ public class BooleanCellVisitor extends CellVisitor {
38
38
  @Override
39
39
  public void visitSheetName(Column column) {
40
40
  Sheet sheet = visitorValue.getSheet();
41
+ visitSheetName(column, sheet);
42
+ }
43
+
44
+ @Override
45
+ public void visitSheetName(Column column, Sheet sheet) {
41
46
  int index = sheet.getWorkbook().getSheetIndex(sheet);
42
47
  pageBuilder.setBoolean(column, index != 0);
43
48
  }
@@ -3,6 +3,7 @@ package org.embulk.parser.poi_excel.visitor.embulk;
3
3
  import java.text.MessageFormat;
4
4
 
5
5
  import org.apache.poi.ss.usermodel.Cell;
6
+ import org.apache.poi.ss.usermodel.Sheet;
6
7
  import org.embulk.config.ConfigException;
7
8
  import org.embulk.parser.poi_excel.bean.PoiExcelColumnBean;
8
9
  import org.embulk.parser.poi_excel.bean.PoiExcelColumnBean.ErrorStrategy;
@@ -40,6 +41,8 @@ public abstract class CellVisitor {
40
41
 
41
42
  public abstract void visitSheetName(Column column);
42
43
 
44
+ public abstract void visitSheetName(Column column, Sheet sheet);
45
+
43
46
  public abstract void visitRowNumber(Column column, int index1);
44
47
 
45
48
  public abstract void visitColumnNumber(Column column, int index1);
@@ -45,6 +45,11 @@ public class DoubleCellVisitor extends CellVisitor {
45
45
  @Override
46
46
  public void visitSheetName(Column column) {
47
47
  Sheet sheet = visitorValue.getSheet();
48
+ visitSheetName(column, sheet);
49
+ }
50
+
51
+ @Override
52
+ public void visitSheetName(Column column, Sheet sheet) {
48
53
  int index = sheet.getWorkbook().getSheetIndex(sheet);
49
54
  pageBuilder.setDouble(column, index);
50
55
  }
@@ -45,6 +45,11 @@ public class LongCellVisitor extends CellVisitor {
45
45
  @Override
46
46
  public void visitSheetName(Column column) {
47
47
  Sheet sheet = visitorValue.getSheet();
48
+ visitSheetName(column, sheet);
49
+ }
50
+
51
+ @Override
52
+ public void visitSheetName(Column column, Sheet sheet) {
48
53
  int index = sheet.getWorkbook().getSheetIndex(sheet);
49
54
  pageBuilder.setLong(column, index);
50
55
  }