registerGridAsSheet method

void registerGridAsSheet(
  1. String refName,
  2. Worksheet model,
  3. int sheetFamilyID
)

register_gridAsSheet is a method that registers an Worksheet Object so it can be referenced in a formula from another Worksheet Object.

Implementation

void registerGridAsSheet(String refName, Worksheet model, int sheetFamilyID) {
  refName = refName.replaceAll("'", "''");

  modelToSheetID ??= <dynamic, dynamic>{};

  if (modelToSheetID![model] == null) {
    modelToSheetID![model] = sheetFamilyID;
  }
  final SheetFamilyItem? family = _getSheetFamilyItem(model);

  family!.isSheeted = true;

  final String refName1 = refName.toUpperCase();

  family.sheetNameToParentObject ??= <dynamic, dynamic>{};

  family.tokenToParentObject ??= <dynamic, dynamic>{};

  family.sheetNameToToken ??= <dynamic, dynamic>{};

  family.parentObjectToToken ??= <dynamic, dynamic>{};

  if (family.sheetNameToParentObject!.containsKey(refName1)) {
    final String token = family.sheetNameToToken![refName1] as String;

    family.tokenToParentObject![token] = model;
    family.parentObjectToToken![model] = token;
  } else {
    final String token = _sheetToken + _tokenCount.toString() + _sheetToken;
    _tokenCount++;

    family.tokenToParentObject![token] = model;
    family.sheetNameToToken![refName1] = token;
    family.sheetNameToParentObject![refName1] = model;
    family.parentObjectToToken![model] = token;
    _sortedSheetNames = null;
  }
}