/** * Used to decide whether sheet names like 'AB123' need delimiting due to the fact that they * look like cell references. * <p> * This code is currently being used for translating formulas represented with <code>Ptg</code> * tokens into human readable text form. In formula expressions, a sheet name always has a * trailing '!' so there is little chance for ambiguity. It doesn't matter too much what this * method returns but it is worth noting the likely consumers of these formula text strings: * <ol> * <li>POI's own formula parser</li> * <li>Visual reading by human</li> * <li>VBA automation entry into Excel cell contents e.g. ActiveCell.Formula = "=c64!A1"</li> * <li>Manual entry into Excel cell contents</li> * <li>Some third party formula parser</li> * </ol> * * At the time of writing, POI's formula parser tolerates cell-like sheet names in formulas * with or without delimiters. The same goes for Excel(2007), both manual and automated entry. * <p> * For better or worse this implementation attempts to replicate Excel's formula renderer. * Excel uses range checking on the apparent 'row' and 'column' components. Note however that * the maximum sheet size varies across versions. * @see org.apache.poi.ss.util.CellReference */ /* package */ static boolean cellReferenceIsWithinRange(String lettersPrefix, String numbersSuffix) { return CellReference.cellReferenceIsWithinRange(lettersPrefix, numbersSuffix, SpreadsheetVersion.EXCEL97); }
String col = name.replaceAll("\\d", ""); String row = name.replaceAll("[A-Za-z]", ""); if (CellReference.cellReferenceIsWithinRange(col, row, SpreadsheetVersion.EXCEL97)) { throw new IllegalArgumentException("Invalid name: '"+name+"': cannot be $A$1-style cell reference");
if (cellReferenceIsWithinRange(lettersGroup, digitsGroup, ssVersion)) {
if (CellReference.cellReferenceIsWithinRange(col, row, SpreadsheetVersion.EXCEL2007)) { throw new IllegalArgumentException("Invalid name: '"+name+"': cannot be $A$1-style cell reference");
/** * Used to decide whether sheet names like 'AB123' need delimiting due to the fact that they * look like cell references. * <p/> * This code is currently being used for translating formulas represented with <code>Ptg</code> * tokens into human readable text form. In formula expressions, a sheet name always has a * trailing '!' so there is little chance for ambiguity. It doesn't matter too much what this * method returns but it is worth noting the likely consumers of these formula text strings: * <ol> * <li>POI's own formula parser</li> * <li>Visual reading by human</li> * <li>VBA automation entry into Excel cell contents e.g. ActiveCell.Formula = "=c64!A1"</li> * <li>Manual entry into Excel cell contents</li> * <li>Some third party formula parser</li> * </ol> * * At the time of writing, POI's formula parser tolerates cell-like sheet names in formulas * with or without delimiters. The same goes for Excel(2007), both manual and automated entry. * <p/> * For better or worse this implementation attempts to replicate Excel's formula renderer. * Excel uses range checking on the apparent 'row' and 'column' components. Note however that * the maximum sheet size varies across versions. * @see org.apache.poi.ss.util.CellReference */ /* package */ static boolean cellReferenceIsWithinRange(String lettersPrefix, String numbersSuffix) { return CellReference.cellReferenceIsWithinRange(lettersPrefix, numbersSuffix, SpreadsheetVersion.EXCEL97); }
/** * Used to decide whether sheet names like 'AB123' need delimiting due to the fact that they * look like cell references. * <p> * This code is currently being used for translating formulas represented with <code>Ptg</code> * tokens into human readable text form. In formula expressions, a sheet name always has a * trailing '!' so there is little chance for ambiguity. It doesn't matter too much what this * method returns but it is worth noting the likely consumers of these formula text strings: * <ol> * <li>POI's own formula parser</li> * <li>Visual reading by human</li> * <li>VBA automation entry into Excel cell contents e.g. ActiveCell.Formula = "=c64!A1"</li> * <li>Manual entry into Excel cell contents</li> * <li>Some third party formula parser</li> * </ol> * * At the time of writing, POI's formula parser tolerates cell-like sheet names in formulas * with or without delimiters. The same goes for Excel(2007), both manual and automated entry. * <p> * For better or worse this implementation attempts to replicate Excel's formula renderer. * Excel uses range checking on the apparent 'row' and 'column' components. Note however that * the maximum sheet size varies across versions. * @see org.apache.poi.ss.util.CellReference */ /* package */ static boolean cellReferenceIsWithinRange(String lettersPrefix, String numbersSuffix) { return CellReference.cellReferenceIsWithinRange(lettersPrefix, numbersSuffix, SpreadsheetVersion.EXCEL97); }
/** * Used to decide whether sheet names like 'AB123' need delimiting due to the fact that they * look like cell references. * <p/> * This code is currently being used for translating formulas represented with <code>Ptg</code> * tokens into human readable text form. In formula expressions, a sheet name always has a * trailing '!' so there is little chance for ambiguity. It doesn't matter too much what this * method returns but it is worth noting the likely consumers of these formula text strings: * <ol> * <li>POI's own formula parser</li> * <li>Visual reading by human</li> * <li>VBA automation entry into Excel cell contents e.g. ActiveCell.Formula = "=c64!A1"</li> * <li>Manual entry into Excel cell contents</li> * <li>Some third party formula parser</li> * </ol> * * At the time of writing, POI's formula parser tolerates cell-like sheet names in formulas * with or without delimiters. The same goes for Excel(2007), both manual and automated entry. * <p/> * For better or worse this implementation attempts to replicate Excel's formula renderer. * Excel uses range checking on the apparent 'row' and 'column' components. Note however that * the maximum sheet size varies across versions. * @see org.apache.poi.ss.util.CellReference */ /* package */ static boolean cellReferenceIsWithinRange(String lettersPrefix, String numbersSuffix) { return CellReference.cellReferenceIsWithinRange(lettersPrefix, numbersSuffix, SpreadsheetVersion.EXCEL97); }
String col = name.replaceAll("\\d", ""); String row = name.replaceAll("[A-Za-z]", ""); if (CellReference.cellReferenceIsWithinRange(col, row, SpreadsheetVersion.EXCEL97)) { throw new IllegalArgumentException("Invalid name: '"+name+"': cannot be $A$1-style cell reference");
if (CellReference.cellReferenceIsWithinRange(col, row, SpreadsheetVersion.EXCEL2007)) { throw new IllegalArgumentException("Invalid name: '"+name+"': cannot be $A$1-style cell reference");
if (cellReferenceIsWithinRange(lettersGroup, digitsGroup, ssVersion)) {
if (cellReferenceIsWithinRange(lettersGroup, digitsGroup, ssVersion)) {
if (cellReferenceIsWithinRange(lettersGroup, digitsGroup, ssVersion)) {