Java Code Examples for org.apache.poi.ss.SpreadsheetVersion#getLastColumnName()

The following examples show how to use org.apache.poi.ss.SpreadsheetVersion#getLastColumnName() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CellReference.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
public static boolean isColumnWithinRange(String colStr, SpreadsheetVersion ssVersion) {
    // Equivalent to 0 <= CellReference.convertColStringToIndex(colStr) <= ssVersion.getLastColumnIndex()

    String lastCol = ssVersion.getLastColumnName();
    int lastColLength = lastCol.length();

    int numberOfLetters = colStr.length();
    if(numberOfLetters > lastColLength) {
        // "Sheet1" case etc
        return false; // that was easy
    }
    if(numberOfLetters == lastColLength) {
        if(colStr.toUpperCase(Locale.ROOT).compareTo(lastCol) > 0) {
            return false;
        }
    } else {
        // apparent column name has less chars than max
        // no need to check range
    }
    return true;
}
 
Example 2
Source File: AreaReference.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
public static AreaReference getWholeRow(SpreadsheetVersion version, String start, String end) {
    if (null == version) {
        version = DEFAULT_SPREADSHEET_VERSION;
    }
    return new AreaReference("$A" + start + ":$" + version.getLastColumnName() + end, version);
}