MCPcopy Create free account
hub / github.com/observablehq/framework / fromCellReference

Function fromCellReference

src/client/stdlib/xlsx.js:101–106  ·  view source on GitHub ↗
(s)

Source from the content-addressed store, hash-verified

99// Returns the zero-based indexes from a cell reference.
100// For example: "A1" -> [0, 0], "B2" -> [1, 1], "AA10" -> [26, 9].
101function fromCellReference(s) {
102 const [, sc, sr] = s.match(/^([A-Z]*)(\d*)$/);
103 let c = 0;
104 if (sc) for (let i = 0; i < sc.length; i++) c += Math.pow(26, sc.length - i - 1) * (sc.charCodeAt(i) - 64);
105 return [c ? c - 1 : undefined, sr ? +sr - 1 : undefined];
106}

Callers

nothing calls this directly

Calls 1

matchMethod · 0.80

Tested by

no test coverage detected