Skip to content

spreadsheet_mutations

freecad.datamanager_wb.spreadsheets.spreadsheet_mutations

Mutation helpers for spreadsheet aliases.

Contains operations that modify spreadsheets, such as clearing/removing an alias definition.

removeSpreadsheetAlias(spreadsheet_name, alias_name, *, ctx=None)

Remove (clear) a spreadsheet alias definition.

This function resolves the cell associated with an alias and then clears the alias using Spreadsheet::Sheet.setAlias.

The implementation supports FreeCAD versions with different alias APIs by attempting: - getCellFromAlias when available - a local alias map extracted via getAliases/properties or getAlias(cell)

Parameters:

Name Type Description Default
spreadsheet_name str

Name of the Spreadsheet::Sheet object.

required
alias_name str

Alias to remove.

required

Returns:

Type Description
bool

True if the alias was cleared, otherwise False.

Source code in freecad/datamanager_wb/spreadsheets/spreadsheet_mutations.py
def removeSpreadsheetAlias(
    spreadsheet_name: str,
    alias_name: str,
    *,
    ctx: FreeCadContext | None = None,
) -> bool:
    """Remove (clear) a spreadsheet alias definition.

    This function resolves the cell associated with an alias and then clears the
    alias using `Spreadsheet::Sheet.setAlias`.

    The implementation supports FreeCAD versions with different alias APIs by
    attempting:
    - `getCellFromAlias` when available
    - a local alias map extracted via `getAliases`/properties or `getAlias(cell)`

    Args:
        spreadsheet_name: Name of the `Spreadsheet::Sheet` object.
        alias_name: Alias to remove.

    Returns:
        ``True`` if the alias was cleared, otherwise ``False``.
    """
    sheet = _try_get_spreadsheet(spreadsheet_name, ctx=ctx)
    if sheet is None:
        return False

    cell = _try_get_cell_from_alias(sheet, alias_name)
    if not cell:
        return False

    return _try_clear_alias(sheet, cell)