1
2
3
4
5
6
7
8
9
10
11 package org.csveed.common;
12
13 import java.util.Locale;
14
15
16
17
18 public class ColumnExcel extends Column {
19
20
21
22
23
24
25
26 public ColumnExcel(String columnExcel) {
27 super(excelColumnToColumnIndex(columnExcel));
28 }
29
30
31
32
33
34
35
36
37
38 private static int excelColumnToColumnIndex(String excelColumn) {
39 excelColumn = excelColumn.toUpperCase(Locale.getDefault());
40 int sum = 0;
41 for (int i = 0; i < excelColumn.length(); i++) {
42 char currentChar = excelColumn.charAt(i);
43 sum *= 26;
44 sum += currentChar - 'A' + 1;
45 }
46 return sum;
47 }
48
49 }