I am receiving reference value as follows when StreamingSheetReader.handleElement's startElement.getName().getLocalPart() is "dimension"
1- ref=A1 (when there is only 1 sheet)
2- ref=A1:AU5121 (when there are 2 or more sheets)
Your code is working fine in 2nd case but it always return 0 in first case. Please suggest some solution.
if(ref != null) {
// ref is formatted as A1 or A1:F25. Take the last numbers of this string and use it as lastRowNum
for(int i = ref.length() - 1; i >= 0; i--) {
if(!Character.isDigit(ref.charAt(i))) {
try {
lastRowNum = Integer.parseInt(ref.substring(i + 1)) - 1;
} catch(NumberFormatException ignore) { }
break;
}
}
}
Hello,
I am receiving reference value as follows when StreamingSheetReader.handleElement's startElement.getName().getLocalPart() is "dimension" 1- ref=A1 (when there is only 1 sheet) 2- ref=A1:AU5121 (when there are 2 or more sheets) Your code is working fine in 2nd case but it always return 0 in first case. Please suggest some solution.
if(ref != null) { // ref is formatted as A1 or A1:F25. Take the last numbers of this string and use it as lastRowNum for(int i = ref.length() - 1; i >= 0; i--) { if(!Character.isDigit(ref.charAt(i))) { try { lastRowNum = Integer.parseInt(ref.substring(i + 1)) - 1; } catch(NumberFormatException ignore) { } break; } } }
Regards,
Mubashar Ahmad