Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for columns AA-ZZ #5891

Merged
merged 1 commit into from
May 31, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -359,21 +359,43 @@ public void startElement(String uri, String localName, String name,
cellContents = "";
}

/* Works from 1-702 columns. Could be made recursive to work beyond that*/
private int getColumnCount(String columnTag) {
int count = -1;
if (columnTag.length() == 1 && columnTag.matches("[A-Z]")) {
count = columnTag.charAt(0) - 'A';
} else {
dbglog.warning("Unsupported column index tag: "+columnTag);
if (columnTag.length() == 2) {
int c1 = columnTag.charAt(0) - 'A';
int c2 = columnTag.charAt(1) - 'A';
if (c1 >= 0 && c1 < 26 && c2 >= 0 && c2 < 26) {
dbglog.fine(columnTag + ": " + ((c1 + 1) * 26 + c2));
return ((c1 + 1) * 26 + c2);
} else {
dbglog.warning("Unsupported column index tag: " + columnTag);
}
} else {
dbglog.warning("Unsupported column index tag: " + columnTag);
}
}

return count;
}

/* Supports A-Z and AA-ZZ (0-701 column count/position) */
private String getColumnLetterTag(int columnCount) {
if (columnCount < 0 || columnCount > 25) {
dbglog.warning("Multi-letter column codes not yet supported.");
return null;
if(columnCount >25 && columnCount < 702) { //AA-ZZ
int code1 = 'A' + columnCount/26 -1;
int code2 = 'A' + columnCount%26;
char[] letterTag = new char[2];
letterTag[0] = (char)code1;
letterTag[1] = (char)code2;
dbglog.fine(columnCount + ": " + new String(letterTag));
return new String(letterTag);
} else {
dbglog.warning("3+ letter column codes not yet supported.");
return null;
}
}
int letterCode = 'A' + columnCount;
char[] letterTag = new char[1];
Expand Down