MCPcopy
hub / github.com/exceljs/exceljs / DefinedNames

Class DefinedNames

lib/doc/defined-names.js:10–194  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8const rangeRegexp = /[$](\w+)[$](\d+)(:[$](\w+)[$](\d+))?/;
9
10class DefinedNames {
11 constructor() {
12 this.matrixMap = {};
13 }
14
15 getMatrix(name) {
16 const matrix = this.matrixMap[name] || (this.matrixMap[name] = new CellMatrix());
17 return matrix;
18 }
19
20 // add a name to a cell. locStr in the form SheetName!$col$row or SheetName!$c1$r1:$c2:$r2
21 add(locStr, name) {
22 const location = colCache.decodeEx(locStr);
23 this.addEx(location, name);
24 }
25
26 addEx(location, name) {
27 const matrix = this.getMatrix(name);
28 if (location.top) {
29 for (let col = location.left; col <= location.right; col++) {
30 for (let row = location.top; row <= location.bottom; row++) {
31 const address = {
32 sheetName: location.sheetName,
33 address: colCache.n2l(col) + row,
34 row,
35 col,
36 };
37
38 matrix.addCellEx(address);
39 }
40 }
41 } else {
42 matrix.addCellEx(location);
43 }
44 }
45
46 remove(locStr, name) {
47 const location = colCache.decodeEx(locStr);
48 this.removeEx(location, name);
49 }
50
51 removeEx(location, name) {
52 const matrix = this.getMatrix(name);
53 matrix.removeCellEx(location);
54 }
55
56 removeAllNames(location) {
57 _.each(this.matrixMap, matrix => {
58 matrix.removeCellEx(location);
59 });
60 }
61
62 forEach(callback) {
63 _.each(this.matrixMap, (matrix, name) => {
64 matrix.forEach(cell => {
65 callback(name, cell);
66 });
67 });

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…