embulk-parser-poi_excel 0.1.11 → 0.1.12

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3ac332670f656bcf9bbf5fe659b53a9a5d61ed34
4
- data.tar.gz: b08187d453742b61242f3c0a414b859e7b3df605
3
+ metadata.gz: 0ce575511ee0ce2d0a9496f1d63013909d751504
4
+ data.tar.gz: f79c800fd6454ba5e2511e6e675a3465c3c2c7d3
5
5
  SHA512:
6
- metadata.gz: d10568439d7728ce805c8a4945dce146b3c5b3983b1be2433b13986a07be0ac0cb52763daebe5c2cc0e0154403e3ec3a3fbbc57e1ff6112afb01a23157ad11da
7
- data.tar.gz: e3b6f6efa059db9b8994ae78700cc8c50f67d80059b76eb41dafbc1b5ce26f1b133c1def929a7e4aa1d1f0fdaaff0d174683d2dba86956948276d2038275dd2e
6
+ metadata.gz: a4ddf5f3506c56924bbe9147c6b23e40f31853356b53e91215120ef9f930e322db50a60a9c2277bc51c863cf588610e44d18cf5ec401a0d8b31d0c7ff30f4b50
7
+ data.tar.gz: bf22e1256df159efd21cdf40d98ae014c8ddf1dc053848dce95a2635fa68dbac2d174833731f5ff700d814fc98a680ab666774b15cce49c24d7a94eea87d6ac1
data/README.md CHANGED
@@ -20,7 +20,7 @@ in:
20
20
  skip_header_lines: 1 # first row is header.
21
21
  columns:
22
22
  - {name: row, type: long, value: row_number}
23
- - {name: get_date, type: timestamp, value: cell_value, column_number: A}
23
+ - {name: get_date, type: timestamp, cell_column: A, value: cell_value}
24
24
  - {name: orb_type, type: string}
25
25
  - {name: orb_name, type: string}
26
26
  - {name: orb_shape, type: long}
@@ -28,13 +28,14 @@ in:
28
28
  ```
29
29
 
30
30
  if omit **value**, specified `cell_value`.
31
- if omit **column_number** when **value** is `cell_value`, specified next column.
31
+ if omit **cell_column** when **value** is `cell_value`, specified next column.
32
32
 
33
33
 
34
34
  ## Configuration
35
35
 
36
36
  * **sheets**: sheet name. can use wildcards `*`, `?`. (list of string, required)
37
- * **skip_header_lines**: skip rows. (integer, default: `0`)
37
+ * **record_type**: record type. (`row`, `column` or `sheet`. default: `row`)
38
+ * **skip_header_lines**: skip rows when **record_type**=`row` (skip columns when **record_type**=`column`). ignored when **record_type**=`sheet`. (integer, default: `0`)
38
39
  * **columns**: column definition. see below. (hash, required)
39
40
  * **sheet_options**: sheet option. see below. (hash, default: null)
40
41
 
@@ -42,9 +43,11 @@ if omit **column_number** when **value** is `cell_value`, specified next column.
42
43
 
43
44
  * **name**: Embulk column name. (string, required)
44
45
  * **type**: Embulk column type. (string, required)
45
- * **value**: value type. see below. (string, defualt: `cell_value`)
46
- * **column_number**: Excel column number. see below. (string, default: next column)
47
- * **cell_address**: Excel cell address such as `A1`, `Sheet1!B3`. only one of `column_number`, `cell_address` can be specified. (string, not required)
46
+ * **value**: value type. see below. (string, default: `cell_value`)
47
+ * **column_number**: same as **cell_column**.
48
+ * **cell_column**: Excel column number. see below. (string, default: next column when **record_type**=`row`)
49
+ * **cell_row**: Excel row number. see below. (integer, default: next row when **record_type**=`column`)
50
+ * **cell_address**: Excel cell address such as `A1`, `Sheet1!B3`. (string, not required)
48
51
  * **numeric_format**: format of numeric(double) to string such as `%4.2f`. (default: Java's Double.toString())
49
52
  * **attribute_name**: use with value `cell_style`, `cell_font`, etc. see below. (list of string)
50
53
  * **on_cell_error**: processing method of Cell error. see below. (string, default: `constant`)
@@ -71,7 +74,9 @@ if omit **column_number** when **value** is `cell_value`, specified next column.
71
74
  * `constant.`*value*: specified value.
72
75
  * `constant`: null.
73
76
 
74
- ### column_number
77
+ ### cell_column
78
+
79
+ Basically used for **record_type**=`row`.
75
80
 
76
81
  * `A`,`B`,`C`,...: column number of "A1 format".
77
82
  * *number*: column number (1 origin).
@@ -84,6 +89,12 @@ if omit **column_number** when **value** is `cell_value`, specified next column.
84
89
  * `=`: same column.
85
90
  * `=`*name*: same column of name.
86
91
 
92
+ ### cell_row
93
+
94
+ Basically used for **record_type**=`column`.
95
+
96
+ * *number*: row number (1 origin).
97
+
87
98
  ### attribute_name
88
99
 
89
100
  **value**が`cell_style`, `cell_font`, `cell_comment`のとき、デフォルトでは、全属性を取得してJSON文字列に変換します。
@@ -91,7 +102,7 @@ if omit **column_number** when **value** is `cell_value`, specified next column.
91
102
 
92
103
  ```yaml
93
104
  columns:
94
- - {name: foo, type: string, column_number: A, value: cell_style}
105
+ - {name: foo, type: string, cell_column: A, value: cell_style}
95
106
  ```
96
107
 
97
108
 
@@ -101,7 +112,7 @@ attribute_nameを指定することで、指定された属性だけを取得し
101
112
 
102
113
  ```yaml
103
114
  columns:
104
- - {name: foo, type: string, column_number: A, value: cell_style, attribute_name: [border_top, border_bottom, border_left, border_right]}
115
+ - {name: foo, type: string, cell_column: A, value: cell_style, attribute_name: [border_top, border_bottom, border_left, border_right]}
105
116
  ```
106
117
 
107
118
 
@@ -114,8 +125,8 @@ attribute_nameを指定することで、指定された属性だけを取得し
114
125
  - {name: bar, type: long, value: cell_font.color}
115
126
  ```
116
127
 
117
- なお、`cell_style`や`cell_font`では、**column_number**を省略した場合は直前と同じ列を対象とします。
118
- (`cell_value`では、**column_number**を省略すると次の列に移る)
128
+ なお、`cell_style`や`cell_font`では、**cell_column**を省略した場合は直前と同じ列を対象とします。
129
+ (`cell_value`では、**cell_column**を省略すると次の列に移る)
119
130
 
120
131
 
121
132
  ### on_cell_error
@@ -124,7 +135,7 @@ Processing method of Cell error (`#DIV/0!`, `#REF!`, etc).
124
135
 
125
136
  ```yaml
126
137
  columns:
127
- - {name: foo, type: string, column_number: A, value: cell_value, on_cell_error: error_code}
138
+ - {name: foo, type: string, cell_column: A, value: cell_value, on_cell_error: error_code}
128
139
  ```
129
140
 
130
141
  * `constant`: set null. (default)
@@ -139,7 +150,7 @@ Processing method of formula.
139
150
 
140
151
  ```yaml
141
152
  columns:
142
- - {name: foo, type: string, column_number: A, value: cell_value, formula_handling: cashed_value}
153
+ - {name: foo, type: string, cell_column: A, value: cell_value, formula_handling: cashed_value}
143
154
  ```
144
155
 
145
156
  * `evaluate`: evaluate formula. (default)
@@ -152,11 +163,11 @@ Processing method of evaluate formula error.
152
163
 
153
164
  ```yaml
154
165
  columns:
155
- - {name: foo, type: string, column_number: A, value: cell_value, on_evaluate_error: constant}
166
+ - {name: foo, type: string, cell_column: A, value: cell_value, on_evaluate_error: constant}
156
167
  ```
157
168
 
158
169
  * `constant`: set null.
159
- * `constant.`*value*: set value.
170
+ * `constant.`*value*: set specified value.
160
171
  * `exception`: throw exception. (default)
161
172
 
162
173
 
@@ -166,10 +177,11 @@ Replace formula before evaluate.
166
177
 
167
178
  ```yaml
168
179
  columns:
169
- - {name: foo, type: string, column_number: A, value: cell_value, formula_replace: [{regex: aaa, to: "A${row}"}, {regex: bbb, to: "B${row}"}]}
180
+ - {name: foo, type: string, cell_column: A, value: cell_value, formula_replace: [{regex: aaa, to: "A${row}"}, {regex: bbb, to: "B${row}"}]}
170
181
  ```
171
182
 
172
183
  `${row}` is replaced with the current row number.
184
+ `${column}` is replaced with the current column string.
173
185
 
174
186
 
175
187
  ### on_convert_error
@@ -178,11 +190,11 @@ Processing method of convert error. ex) Excel boolean to Embulk timestamp
178
190
 
179
191
  ```yaml
180
192
  columns:
181
- - {name: foo, type: timestamp, format: "%Y/%m/%d", column_number: A, value: cell_value, on_convert_error: constant.9999/12/31}
193
+ - {name: foo, type: timestamp, format: "%Y/%m/%d", cell_column: A, value: cell_value, on_convert_error: constant.9999/12/31}
182
194
  ```
183
195
 
184
196
  * `constant`: set null.
185
- * `constant.`*value*: set value.
197
+ * `constant.`*value*: set specified value.
186
198
  * `exception`: throw exception. (default)
187
199
 
188
200
 
@@ -195,19 +207,19 @@ Options of individual sheet.
195
207
  type: poi_excel
196
208
  sheets: [Sheet1, Sheet2]
197
209
  columns:
198
- - {name: date, type: timestamp, column_number: A}
210
+ - {name: date, type: timestamp, cell_column: A}
199
211
  - {name: foo, type: string}
200
212
  - {name: bar, type: long}
201
213
  sheet_options:
202
214
  Sheet1:
203
215
  skip_header_lines: 1
204
216
  columns:
205
- foo: {column_number: B}
206
- bar: {column_number: C}
217
+ foo: {cell_column: B}
218
+ bar: {cell_column: C}
207
219
  Sheet2:
208
220
  skip_header_lines: 0
209
221
  columns:
210
- foo: {column_number: D}
222
+ foo: {cell_column: D}
211
223
  bar: {value: constant.0}
212
224
  ```
213
225
 
@@ -13,7 +13,7 @@ configurations {
13
13
  provided
14
14
  }
15
15
 
16
- version = "0.1.11"
16
+ version = "0.1.12"
17
17
 
18
18
  sourceCompatibility = 1.7
19
19
  targetCompatibility = 1.7
@@ -57,6 +57,12 @@ task "package"(dependsOn: ["gemspec", "classpath"]) {
57
57
  }
58
58
  }
59
59
 
60
+ task gemUnpack(type: JRubyExec) {
61
+ jrubyArgs "-S"
62
+ script "gem"
63
+ scriptArgs "unpack", "pkg/${project.name}-${project.version}.gem"
64
+ }
65
+
60
66
  task gemspec {
61
67
  ext.gemspecFile = file("${project.name}.gemspec")
62
68
  inputs.file "build.gradle"
@@ -1,5 +1,7 @@
1
1
  package org.embulk.parser.poi_excel;
2
2
 
3
+ import org.embulk.parser.poi_excel.bean.record.RecordType;
4
+
3
5
  public enum PoiExcelColumnValueType {
4
6
  /** cell value */
5
7
  CELL_VALUE(true, true),
@@ -18,9 +20,25 @@ public enum PoiExcelColumnValueType {
18
20
  /** sheet name */
19
21
  SHEET_NAME(false, false),
20
22
  /** row number (1 origin) */
21
- ROW_NUMBER(false, false),
23
+ ROW_NUMBER(false, false) {
24
+ @Override
25
+ public boolean useCell(RecordType recordType) {
26
+ if (recordType == RecordType.COLUMN) {
27
+ return true;
28
+ }
29
+ return super.useCell(recordType);
30
+ }
31
+ },
22
32
  /** column number (1 origin) */
23
- COLUMN_NUMBER(true, false),
33
+ COLUMN_NUMBER(true, false) {
34
+ @Override
35
+ public boolean useCell(RecordType recordType) {
36
+ if (recordType == RecordType.ROW) {
37
+ return true;
38
+ }
39
+ return super.useCell(recordType);
40
+ }
41
+ },
24
42
  /** constant */
25
43
  CONSTANT(false, false);
26
44
 
@@ -32,7 +50,7 @@ public enum PoiExcelColumnValueType {
32
50
  this.nextIndex = nextIndex;
33
51
  }
34
52
 
35
- public boolean useCell() {
53
+ public boolean useCell(RecordType recordType) {
36
54
  return useCell;
37
55
  }
38
56
 
@@ -10,7 +10,6 @@ import java.util.regex.Pattern;
10
10
 
11
11
  import org.apache.poi.EncryptedDocumentException;
12
12
  import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
13
- import org.apache.poi.ss.usermodel.Row;
14
13
  import org.apache.poi.ss.usermodel.Sheet;
15
14
  import org.apache.poi.ss.usermodel.Workbook;
16
15
  import org.apache.poi.ss.usermodel.WorkbookFactory;
@@ -20,6 +19,8 @@ import org.embulk.config.ConfigException;
20
19
  import org.embulk.config.ConfigSource;
21
20
  import org.embulk.config.Task;
22
21
  import org.embulk.config.TaskSource;
22
+ import org.embulk.parser.poi_excel.bean.PoiExcelSheetBean;
23
+ import org.embulk.parser.poi_excel.bean.record.PoiExcelRecord;
23
24
  import org.embulk.parser.poi_excel.visitor.PoiExcelColumnVisitor;
24
25
  import org.embulk.parser.poi_excel.visitor.PoiExcelVisitorFactory;
25
26
  import org.embulk.parser.poi_excel.visitor.PoiExcelVisitorValue;
@@ -69,6 +70,10 @@ public class PoiExcelParserPlugin implements ParserPlugin {
69
70
 
70
71
  public interface SheetCommonOptionTask extends Task, ColumnCommonOptionTask {
71
72
 
73
+ @Config("record_type")
74
+ @ConfigDefault("null")
75
+ public Optional<String> getRecordType();
76
+
72
77
  @Config("skip_header_lines")
73
78
  @ConfigDefault("null")
74
79
  public Optional<Integer> getSkipHeaderLines();
@@ -91,11 +96,25 @@ public class PoiExcelParserPlugin implements ParserPlugin {
91
96
  @ConfigDefault("null")
92
97
  public Optional<String> getValueType();
93
98
 
94
- // A,B,... or number(1 origin)
99
+ // same as cell_column
95
100
  @Config("column_number")
96
101
  @ConfigDefault("null")
97
102
  public Optional<String> getColumnNumber();
98
103
 
104
+ public static final String CELL_COLUMN = "cell_column";
105
+
106
+ // A,B,... or number(1 origin)
107
+ @Config(CELL_COLUMN)
108
+ @ConfigDefault("null")
109
+ public Optional<String> getCellColumn();
110
+
111
+ public static final String CELL_ROW = "cell_row";
112
+
113
+ // number(1 origin)
114
+ @Config(CELL_ROW)
115
+ @ConfigDefault("null")
116
+ public Optional<String> getCellRow();
117
+
99
118
  // A1,B2,... or Sheet1!A1
100
119
  @Config("cell_address")
101
120
  @ConfigDefault("null")
@@ -256,21 +275,18 @@ public class PoiExcelParserPlugin implements ParserPlugin {
256
275
  log.info("sheet={}", sheetName);
257
276
  PoiExcelVisitorFactory factory = newPoiExcelVisitorFactory(task, schema, sheet, pageBuilder);
258
277
  PoiExcelColumnVisitor visitor = factory.getPoiExcelColumnVisitor();
259
- final int skipHeaderLines = factory.getVisitorValue().getSheetBean().getSkipHeaderLines();
278
+ PoiExcelSheetBean sheetBean = factory.getVisitorValue().getSheetBean();
279
+ final int skipHeaderLines = sheetBean.getSkipHeaderLines();
280
+
281
+ PoiExcelRecord record = sheetBean.getRecordType().newPoiExcelRecord();
282
+ record.initialize(sheet, skipHeaderLines);
283
+ visitor.setRecord(record);
260
284
 
261
285
  int count = 0;
262
- for (Row row : sheet) {
263
- int rowIndex = row.getRowNum();
264
- if (rowIndex < skipHeaderLines) {
265
- log.debug("row({}) skipped", rowIndex);
266
- continue;
267
- }
268
- if (log.isDebugEnabled()) {
269
- log.debug("row({}) start", rowIndex);
270
- }
286
+ for (; record.exists(); record.moveNext()) {
287
+ record.logStart();
271
288
 
272
- visitor.setRow(row);
273
- schema.visitColumns(visitor);
289
+ schema.visitColumns(visitor); // use record
274
290
  pageBuilder.addRecord();
275
291
 
276
292
  if (++count >= flushCount) {
@@ -279,9 +295,7 @@ public class PoiExcelParserPlugin implements ParserPlugin {
279
295
  count = 0;
280
296
  }
281
297
 
282
- if (log.isDebugEnabled()) {
283
- log.debug("row({}) end", rowIndex);
284
- }
298
+ record.logEnd();
285
299
  }
286
300
  pageBuilder.flush();
287
301
  }
@@ -5,6 +5,7 @@ import java.util.ArrayList;
5
5
  import java.util.Collections;
6
6
  import java.util.List;
7
7
 
8
+ import org.apache.poi.ss.util.CellReference;
8
9
  import org.embulk.config.ConfigException;
9
10
  import org.embulk.parser.poi_excel.PoiExcelColumnValueType;
10
11
  import org.embulk.parser.poi_excel.PoiExcelParserPlugin.ColumnCommonOptionTask;
@@ -101,6 +102,12 @@ public class PoiExcelColumnBean {
101
102
  }
102
103
 
103
104
  public Optional<String> getColumnNumber() {
105
+ for (ColumnOptionTask task : columnTaskList) {
106
+ Optional<String> option = task.getCellColumn();
107
+ if (option.isPresent()) {
108
+ return option;
109
+ }
110
+ }
104
111
  for (ColumnOptionTask task : columnTaskList) {
105
112
  Optional<String> option = task.getColumnNumber();
106
113
  if (option.isPresent()) {
@@ -110,6 +117,16 @@ public class PoiExcelColumnBean {
110
117
  return Optional.absent();
111
118
  }
112
119
 
120
+ public Optional<String> getRowNumber() {
121
+ for (ColumnOptionTask task : columnTaskList) {
122
+ Optional<String> option = task.getCellRow();
123
+ if (option.isPresent()) {
124
+ return option;
125
+ }
126
+ }
127
+ return Optional.absent();
128
+ }
129
+
113
130
  private Optional<PoiExcelCellAddress> cellAddress;
114
131
 
115
132
  public PoiExcelCellAddress getCellAddress() {
@@ -123,12 +140,17 @@ public class PoiExcelColumnBean {
123
140
  for (ColumnOptionTask task : columnTaskList) {
124
141
  Optional<String> option = task.getCellAddress();
125
142
  if (option.isPresent()) {
126
- return Optional.of(new PoiExcelCellAddress(option.get()));
143
+ CellReference ref = new CellReference(option.get());
144
+ return Optional.of(new PoiExcelCellAddress(ref));
127
145
  }
128
146
  }
129
147
  return Optional.absent();
130
148
  }
131
149
 
150
+ public void setCellAddress(CellReference ref) {
151
+ this.cellAddress = Optional.of(new PoiExcelCellAddress(ref));
152
+ }
153
+
132
154
  protected abstract class CacheValue<T> {
133
155
  private T value;
134
156
 
@@ -7,7 +7,9 @@ import java.util.Map;
7
7
 
8
8
  import org.apache.poi.ss.util.CellReference;
9
9
  import org.embulk.parser.poi_excel.PoiExcelColumnValueType;
10
+ import org.embulk.parser.poi_excel.PoiExcelParserPlugin.ColumnOptionTask;
10
11
  import org.embulk.parser.poi_excel.PoiExcelParserPlugin.PluginTask;
12
+ import org.embulk.parser.poi_excel.bean.record.RecordType;
11
13
  import org.embulk.parser.poi_excel.bean.util.PoiExcelCellAddress;
12
14
  import org.embulk.spi.Column;
13
15
  import org.embulk.spi.Exec;
@@ -19,18 +21,26 @@ import com.google.common.base.Optional;
19
21
  public class PoiExcelColumnIndex {
20
22
  private final Logger log = Exec.getLogger(getClass());
21
23
 
24
+ protected final RecordType recordType;
22
25
  protected final Map<String, Integer> indexMap = new LinkedHashMap<>();
23
26
 
27
+ public PoiExcelColumnIndex(PoiExcelSheetBean sheetBean) {
28
+ this.recordType = sheetBean.getRecordType();
29
+ }
30
+
24
31
  public void initializeColumnIndex(PluginTask task, List<PoiExcelColumnBean> beanList) {
32
+ log.info("record_type={}", recordType);
33
+
25
34
  int index = -1;
26
35
  indexMap.clear();
27
36
 
28
37
  Schema schema = task.getColumns().toSchema();
29
38
  for (Column column : schema.getColumns()) {
30
39
  PoiExcelColumnBean bean = beanList.get(column.getIndex());
31
- PoiExcelColumnValueType valueType = bean.getValueType();
40
+ initializeCellAddress(column, bean);
32
41
 
33
- if (valueType.useCell()) {
42
+ PoiExcelColumnValueType valueType = bean.getValueType();
43
+ if (valueType.useCell(recordType)) {
34
44
  index = resolveColumnIndex(column, bean, index, valueType);
35
45
  if (index < 0) {
36
46
  index = 0;
@@ -39,21 +49,74 @@ public class PoiExcelColumnIndex {
39
49
  indexMap.put(column.getName(), index);
40
50
  }
41
51
 
52
+ initializeCellAddress2(column, bean, index);
53
+
42
54
  if (log.isInfoEnabled()) {
43
55
  logColumn(column, bean, valueType, index);
44
56
  }
45
57
  }
46
58
  }
47
59
 
60
+ protected void initializeCellAddress(Column column, PoiExcelColumnBean bean) {
61
+ if (bean.getCellAddress() != null) {
62
+ return;
63
+ }
64
+
65
+ Optional<String> rowOption = bean.getRowNumber();
66
+ Optional<String> colOption = bean.getColumnNumber();
67
+ if (rowOption.isPresent() && colOption.isPresent()) {
68
+ String rowNumber = rowOption.get();
69
+ String colNumber = colOption.get();
70
+ initializeCellAddress(column, bean, rowNumber, colNumber);
71
+ return;
72
+ }
73
+
74
+ if (recordType == RecordType.SHEET) {
75
+ String rowNumber = rowOption.or("1");
76
+ String colNumber = colOption.or("A");
77
+ initializeCellAddress(column, bean, rowNumber, colNumber);
78
+ return;
79
+ }
80
+ }
81
+
82
+ protected void initializeCellAddress(Column column, PoiExcelColumnBean bean, String rowNumber, String columnNumber) {
83
+ int columnIndex = convertColumnIndex(column, OPTION_NAME_CELL_COLUMN, columnNumber);
84
+ int rowIndex = convertColumnIndex(column, OPTION_NAME_CELL_ROW, rowNumber);
85
+ CellReference ref = new CellReference(rowIndex, columnIndex);
86
+ bean.setCellAddress(ref);
87
+ }
88
+
89
+ protected void initializeCellAddress2(Column column, PoiExcelColumnBean bean, int index) {
90
+ if (bean.getCellAddress() != null) {
91
+ return;
92
+ }
93
+
94
+ Optional<String> recordOption = recordType.getRecordOption(bean);
95
+ if (recordOption.isPresent()) {
96
+ int rowIndex, columnIndex;
97
+ switch (recordType) {
98
+ case ROW:
99
+ rowIndex = convertColumnIndex(column, recordType.getRecordOptionName(), recordOption.get());
100
+ columnIndex = (index >= 0) ? index : 0;
101
+ break;
102
+ case COLUMN:
103
+ rowIndex = (index >= 0) ? index : 0;
104
+ columnIndex = convertColumnIndex(column, recordType.getRecordOptionName(), recordOption.get());
105
+ break;
106
+ default:
107
+ throw new IllegalStateException();
108
+ }
109
+ CellReference ref = new CellReference(rowIndex, columnIndex);
110
+ bean.setCellAddress(ref);
111
+ }
112
+ }
113
+
48
114
  protected int resolveColumnIndex(Column column, PoiExcelColumnBean bean, int index,
49
115
  PoiExcelColumnValueType valueType) {
50
- Optional<String> numberOption = bean.getColumnNumber();
116
+ Optional<String> numberOption = recordType.getNumberOption(bean);
51
117
  PoiExcelCellAddress cellAddress = bean.getCellAddress();
52
118
 
53
119
  if (cellAddress != null) {
54
- if (numberOption.isPresent()) {
55
- throw new RuntimeException("only one of column_number, cell_address can be specified");
56
- }
57
120
  return index;
58
121
  }
59
122
 
@@ -73,7 +136,7 @@ public class PoiExcelColumnIndex {
73
136
  break;
74
137
  }
75
138
  }
76
- return convertColumnIndex(column, columnNumber);
139
+ return convertColumnIndex(column, recordType.getNumberOptionName(), columnNumber);
77
140
  } else {
78
141
  if (valueType.nextIndex()) {
79
142
  index++;
@@ -144,11 +207,12 @@ public class PoiExcelColumnIndex {
144
207
 
145
208
  protected void checkIndex(Column column, int index) {
146
209
  if (index < 0) {
147
- throw new RuntimeException(MessageFormat.format("column_number out of range at {0}", column));
210
+ throw new RuntimeException(MessageFormat.format("{0} out of range at {1}",
211
+ recordType.getNumberOptionName(), column));
148
212
  }
149
213
  }
150
214
 
151
- protected int convertColumnIndex(Column column, String columnNumber) {
215
+ protected int convertColumnIndex(Column column, String numberOptionName, String columnNumber) {
152
216
  int index;
153
217
  try {
154
218
  char c = columnNumber.charAt(0);
@@ -158,16 +222,19 @@ public class PoiExcelColumnIndex {
158
222
  index = CellReference.convertColStringToIndex(columnNumber);
159
223
  }
160
224
  } catch (Exception e) {
161
- throw new RuntimeException(MessageFormat.format("illegal column_number=\"{0}\" at {1}", columnNumber,
162
- column), e);
225
+ throw new RuntimeException(MessageFormat.format("illegal {0}=\"{1}\" at {2}", numberOptionName,
226
+ columnNumber, column), e);
163
227
  }
164
228
  if (index < 0) {
165
- throw new RuntimeException(MessageFormat.format("illegal column_number=\"{0}\" at {1}", columnNumber,
166
- column));
229
+ throw new RuntimeException(MessageFormat.format("illegal {0}=\"{1}\" at {2}", numberOptionName,
230
+ columnNumber, column));
167
231
  }
168
232
  return index;
169
233
  }
170
234
 
235
+ private static final String OPTION_NAME_CELL_COLUMN = ColumnOptionTask.CELL_COLUMN;
236
+ private static final String OPTION_NAME_CELL_ROW = ColumnOptionTask.CELL_ROW;
237
+
171
238
  protected void logColumn(Column column, PoiExcelColumnBean bean, PoiExcelColumnValueType valueType, int index) {
172
239
  PoiExcelCellAddress cellAddress = bean.getCellAddress();
173
240
 
@@ -176,8 +243,20 @@ public class PoiExcelColumnIndex {
176
243
  cname = "cell_address";
177
244
  cvalue = cellAddress.getString();
178
245
  } else {
179
- cname = "cell_column";
180
- cvalue = CellReference.convertNumToColString(index);
246
+ switch (recordType) {
247
+ default:
248
+ cname = OPTION_NAME_CELL_COLUMN;
249
+ cvalue = CellReference.convertNumToColString(index);
250
+ break;
251
+ case COLUMN:
252
+ cname = OPTION_NAME_CELL_ROW;
253
+ cvalue = Integer.toString(index + 1);
254
+ break;
255
+ case SHEET:
256
+ cname = "sheet";
257
+ cvalue = null;
258
+ break;
259
+ }
181
260
  }
182
261
 
183
262
  switch (valueType) {
@@ -186,43 +265,47 @@ public class PoiExcelColumnIndex {
186
265
  case CELL_FORMULA:
187
266
  case CELL_TYPE:
188
267
  case CELL_CACHED_TYPE:
189
- case COLUMN_NUMBER:
190
- log.info("column.name={} <- {}={}, value_type={}", column.getName(), cname, cvalue, valueType);
268
+ log.info("column.name={} <- {}={}, value={}", column.getName(), cname, cvalue, valueType);
191
269
  break;
192
270
  case CELL_STYLE:
193
271
  case CELL_FONT:
194
272
  case CELL_COMMENT:
195
273
  String suffix = bean.getValueTypeSuffix();
196
274
  if (suffix != null) {
197
- log.info("column.name={} <- {}={}, value_type={}, value=[{}]", column.getName(), cname, cvalue,
198
- valueType, suffix);
275
+ log.info("column.name={} <- {}={}, value={}[{}]", column.getName(), cname, cvalue, valueType, suffix);
199
276
  } else {
200
- log.info("column.name={} <- {}={}, value_type={}, value={}", column.getName(), cname, cvalue,
201
- valueType, suffix);
277
+ log.info("column.name={} <- {}={}, value={}", column.getName(), cname, cvalue, valueType);
202
278
  }
203
279
  break;
204
280
 
205
281
  case SHEET_NAME:
206
282
  if (cellAddress != null && cellAddress.getSheetName() != null) {
207
- log.info("column.name={} <- {}={}, value_type={}", column.getName(), cname, cvalue, valueType);
283
+ log.info("column.name={} <- {}={}, value={}", column.getName(), cname, cvalue, valueType);
208
284
  } else {
209
- log.info("column.name={} <- value_type={}", column.getName(), valueType);
285
+ log.info("column.name={} <- value={}", column.getName(), valueType);
210
286
  }
211
287
  break;
212
288
  case ROW_NUMBER:
213
- if (cellAddress != null) {
214
- log.info("column.name={} <- {}={}, value_type={}", column.getName(), cname, cvalue, valueType);
289
+ if (cellAddress != null || cname.equals(OPTION_NAME_CELL_ROW)) {
290
+ log.info("column.name={} <- {}={}, value={}", column.getName(), cname, cvalue, valueType);
291
+ } else {
292
+ log.info("column.name={} <- value={}", column.getName(), valueType);
293
+ }
294
+ break;
295
+ case COLUMN_NUMBER:
296
+ if (cellAddress != null || cname.equals(OPTION_NAME_CELL_COLUMN)) {
297
+ log.info("column.name={} <- {}={}, value={}", column.getName(), cname, cvalue, valueType);
215
298
  } else {
216
- log.info("column.name={} <- value_type={}", column.getName(), valueType);
299
+ log.info("column.name={} <- value={}", column.getName(), valueType);
217
300
  }
218
301
  break;
219
302
 
220
303
  case CONSTANT:
221
304
  String value = bean.getValueTypeSuffix();
222
305
  if (value != null) {
223
- log.info("column.name={} <- value_type={}, value=[{}]", column.getName(), valueType, value);
306
+ log.info("column.name={} <- value={}[{}]", column.getName(), valueType, value);
224
307
  } else {
225
- log.info("column.name={} <- value_type={}, value={}", column.getName(), valueType, value);
308
+ log.info("column.name={} <- value={}({})", column.getName(), valueType, value);
226
309
  }
227
310
  break;
228
311
  }