excel cell reference in javascript

Jon Smith

I have a combobox and a textbox in EXTJS 4.

else if (record.get("type") === "CELL_VALUE" && record.get("apply_before") === true)
    {
        Ext.Msg.alert("Field Validation", "I am Validating the CELL VALUE COMBO VALUE"); //alert message for testing only, this is where validation will occur
    }

In this scenario, "type" is a standard combobox and "appy_before" is a checkbox. If type = Cell Value and apply_before is checked, I need to validate a text box (range_from) contains a valid excel cell location, and that a second text box (range_to) is empty and if validation passes, set isValid = true, else isValid = false.

I know part of it should be as follows:

else if (record.get("type") === "CELL_VALUE" && record.get("apply_before") === true)
    {
            if (rangeFrom != (A1 - XFD1048576)**problem here**) || (rangeTo != null)
                    isValid = false;
    }

can anyone please provide a little more direction please as I have no clue how to check for the valid cell location where the range of cells can be anything from

A1 (first possible valid cell) to XFD1048576 (the last possible valid cell)
Cᴏʀʏ

I put together a little validation function for you:

function validateRange(coordinate) {
    // A little input validation
    if (typeof coordinate != "string" || !coordinate.length) 
        return false;
    // Find the first occurrence of a digit
    var startIndex = coordinate.search(/[\d+]/);
    // The column is the part from the beginning up until the first digit
    var column = coordinate.substring(0, startIndex).toUpperCase();
    // The row is the remainder of the string
    var row = parseInt(coordinate.substring(startIndex), 10);
    // The column is sortable alphabetically so we can check its range,
    // and the row is numeric so we can check it's range as well
    return (column >= "A"   && row >= 1) && 
           (column <= "XFD" && row <= 1048576);
}

Give it a whirl:

var str = "XFD100000";
var result = validateRange(str);

Applied to your context:

if (!validateRange(rangeFrom)) {

I don't know exactly how fool-proof this is, but maybe it would give you a good starting point.

Demo

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Excel Sumifs with reference to a cell

From Dev

Powershell find excel cell reference

From Dev

How to reference a cell in a excel hyperlink

From Dev

Advance cell reference on Excel refresh

From Dev

Convert cell reference to text in Excel

From Dev

Excel Cell reference from equation

From Dev

Powershell find excel cell reference

From Dev

Finding a reference to a cell in an excel formula

From Dev

Excel VBA for loop formula with relative cell reference

From Dev

Create dynamic cell block reference in excel formula

From Dev

Excel Max Formula Reference to another cell

From Dev

Excel - Replace offset formula with actual cell reference

From Dev

How to use a cell as a filename in a reference in excel?

From Dev

Excel dynamic drop down linked to a cell reference

From Dev

Relative cell reference in Excel using different axis

From Dev

Reference a cell of the previous row in the same table in Excel?

From Dev

How to reference same cell in previous sheet in excel?

From Dev

Excel VBA for loop formula with relative cell reference

From Dev

Reference cell range on another sheet - Excel

From Dev

Excel - Create cell reference without use of INDIRECT()

From Dev

Excel - leave blank if reference cell is blank

From Dev

How to change cell reference style in Excel Online?

From Dev

Reference every second cell in Excel formula

From Dev

SQL query by date with reference in excel (cell)

From Dev

Reference cell range parameter from other cell dynamically in excel

From Dev

Excel cell reference from closed workbook using file name in cell

From Dev

MS Excel, List of cell reference depends on one cell

From Dev

Excel Formula: Reference a cells value whilst maintaining original cell reference

From Dev

Convert automatically excel table formulas from explicit cell reference to structured cell reference?

Related Related

  1. 1

    Excel Sumifs with reference to a cell

  2. 2

    Powershell find excel cell reference

  3. 3

    How to reference a cell in a excel hyperlink

  4. 4

    Advance cell reference on Excel refresh

  5. 5

    Convert cell reference to text in Excel

  6. 6

    Excel Cell reference from equation

  7. 7

    Powershell find excel cell reference

  8. 8

    Finding a reference to a cell in an excel formula

  9. 9

    Excel VBA for loop formula with relative cell reference

  10. 10

    Create dynamic cell block reference in excel formula

  11. 11

    Excel Max Formula Reference to another cell

  12. 12

    Excel - Replace offset formula with actual cell reference

  13. 13

    How to use a cell as a filename in a reference in excel?

  14. 14

    Excel dynamic drop down linked to a cell reference

  15. 15

    Relative cell reference in Excel using different axis

  16. 16

    Reference a cell of the previous row in the same table in Excel?

  17. 17

    How to reference same cell in previous sheet in excel?

  18. 18

    Excel VBA for loop formula with relative cell reference

  19. 19

    Reference cell range on another sheet - Excel

  20. 20

    Excel - Create cell reference without use of INDIRECT()

  21. 21

    Excel - leave blank if reference cell is blank

  22. 22

    How to change cell reference style in Excel Online?

  23. 23

    Reference every second cell in Excel formula

  24. 24

    SQL query by date with reference in excel (cell)

  25. 25

    Reference cell range parameter from other cell dynamically in excel

  26. 26

    Excel cell reference from closed workbook using file name in cell

  27. 27

    MS Excel, List of cell reference depends on one cell

  28. 28

    Excel Formula: Reference a cells value whilst maintaining original cell reference

  29. 29

    Convert automatically excel table formulas from explicit cell reference to structured cell reference?

HotTag

Archive