jipengfei.jpf
6 years ago
12 changed files with 187 additions and 177 deletions
@ -1,73 +1,71 @@ |
|||||||
package com.alibaba.excel.util; |
//package com.alibaba.excel.util;
|
||||||
|
//
|
||||||
import java.util.ArrayList; |
//import java.util.ArrayList;
|
||||||
import java.util.List; |
//import java.util.List;
|
||||||
import java.util.Stack; |
//import java.util.Stack;
|
||||||
|
//
|
||||||
import com.alibaba.excel.metadata.IndexValue; |
//import com.alibaba.excel.metadata.IndexValue;
|
||||||
|
//
|
||||||
/** |
///**
|
||||||
* 去除空Cell |
// * 去除空Cell
|
||||||
* @author jipengfei |
// * @author jipengfei
|
||||||
*/ |
// */
|
||||||
public class IndexValueConverter { |
//public class IndexValueConverter {
|
||||||
public static List<String> converter(List<IndexValue> i_list) { |
// public static List<String> converter(List<IndexValue> i_list) {
|
||||||
|
//
|
||||||
List<String> tem = new ArrayList<String>(); |
// List<String> tem = new ArrayList<String>();
|
||||||
|
//
|
||||||
char[] start = {'@'}; |
// char[] start = {'@'};
|
||||||
int j = 0; |
// int j = 0;
|
||||||
for (; j < i_list.size(); j++) { |
// for (; j < i_list.size(); j++) {
|
||||||
IndexValue currentIndexValue = i_list.get(j); |
// IndexValue currentIndexValue = i_list.get(j);
|
||||||
char[] currentIndex = currentIndexValue.getV_index().replaceAll("[0-9]", "").toCharArray(); |
// char[] currentIndex = currentIndexValue.getV_index().replaceAll("[0-9]", "").toCharArray();
|
||||||
if (j > 0) { |
// if (j > 0) {
|
||||||
start = i_list.get(j - 1).getV_index().replaceAll("[0-9]", "").toCharArray(); |
// start = i_list.get(j - 1).getV_index().replaceAll("[0-9]", "").toCharArray();
|
||||||
} |
// }
|
||||||
int deep = subtraction26(currentIndex, start); |
// int deep = subtraction26(currentIndex, start);
|
||||||
int k = 0; |
// int k = 0;
|
||||||
for (; k < deep - 1; k++) { |
// for (; k < deep - 1; k++) {
|
||||||
tem.add(null); |
// tem.add(null);
|
||||||
} |
// }
|
||||||
tem.add(currentIndexValue.getV_value()); |
// tem.add(currentIndexValue.getV_value());
|
||||||
} |
// }
|
||||||
return tem; |
// return tem;
|
||||||
} |
// }
|
||||||
|
//
|
||||||
private static int subtraction26(char[] currentIndex, char[] beforeIndex) { |
// private static int subtraction26(char[] currentIndex, char[] beforeIndex) {
|
||||||
int result = 0; |
// int result = 0;
|
||||||
|
//
|
||||||
Stack<Character> currentStack = new Stack<Character>(); |
// Stack<Character> currentStack = new Stack<Character>();
|
||||||
Stack<Character> berforStack = new Stack<Character>(); |
// Stack<Character> beforeStack = new Stack<Character>();
|
||||||
|
//
|
||||||
for (int i = 0; i < currentIndex.length; i++) { |
// for (int i = 0; i < currentIndex.length; i++) {
|
||||||
currentStack.push(currentIndex[i]); |
// currentStack.push(currentIndex[i]);
|
||||||
} |
// }
|
||||||
for (int i = 0; i < beforeIndex.length; i++) { |
// for (int i = 0; i < beforeIndex.length; i++) {
|
||||||
berforStack.push(beforeIndex[i]); |
// beforeStack.push(beforeIndex[i]);
|
||||||
} |
// }
|
||||||
int i = 0; |
// int i = 0;
|
||||||
char beforechar = '@'; |
// char beforeChar = '@';
|
||||||
while (!currentStack.isEmpty()) { |
// while (!currentStack.isEmpty()) {
|
||||||
char currentChar = currentStack.pop(); |
// char currentChar = currentStack.pop();
|
||||||
if (!berforStack.isEmpty()) { |
// if (!beforeStack.isEmpty()) {
|
||||||
beforechar = berforStack.pop(); |
// beforeChar = beforeStack.pop();
|
||||||
} |
// }
|
||||||
int n = currentChar - beforechar; |
// int n = currentChar - beforeChar;
|
||||||
if(n<0){ |
// if(n<0){
|
||||||
n = n+26; |
// n = n+26;
|
||||||
if(!currentStack.isEmpty()){ |
// if(!currentStack.isEmpty()){
|
||||||
char borrow = currentStack.pop(); |
// char borrow = currentStack.pop();
|
||||||
char newBorrow =(char)(borrow -1); |
// char newBorrow =(char)(borrow -1);
|
||||||
currentStack.push(newBorrow); |
// currentStack.push(newBorrow);
|
||||||
} |
// }
|
||||||
} |
// }
|
||||||
|
// result += n * Math.pow(26, i);
|
||||||
|
// i++;
|
||||||
result += n * Math.pow(26, i); |
// beforeChar='@';
|
||||||
i++; |
// }
|
||||||
beforechar='@'; |
//
|
||||||
} |
// return result;
|
||||||
|
// }
|
||||||
return result; |
//}
|
||||||
} |
|
||||||
} |
|
||||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in new issue