Skip to content

wb.scenarios

WorkbookScenarios

8 methods

add

Promise<string>
add(config: ScenarioConfig): Promise<string>;
ParameterTypeRequired
configScenarioConfigrequired

Add a what-if scenario. @param config - Scenario configuration (name, changing cells, values). @returns The newly created scenario's ID.

list

Promise<Scenario[]>
list(): Promise<Scenario[]>;

List all scenarios in the workbook. @returns Array of all saved scenarios.

getActiveScenarioId

Promise<string | null>
getActiveScenarioId(): Promise<string | null>;

Return the session-scoped active scenario id, if a scenario is currently applied.

getActiveScenarioState

Promise<ActiveScenarioState | null>
getActiveScenarioState(): Promise<ActiveScenarioState | null>;

Return session-scoped active scenario state. This is not persisted in workbook storage.

apply

Promise<ApplyScenarioResult>
apply(id: string): Promise<ApplyScenarioResult>;
ParameterTypeRequired
idstringrequired

Apply a scenario's values to the worksheet. @param id - The scenario ID to apply. @returns Result including cells updated count and original values for restore.

restore

Promise<void>
restore(baselineIdOrOriginals: string | OriginalCellValue[]): Promise<void>;
ParameterTypeRequired
baselineIdOrOriginalsstring | OriginalCellValue[]required

Restore original values from a prior apply() call and deactivate the scenario. @param baselineIdOrOriginals - The Rust session baseline ID returned by apply(). Legacy original-value arrays are accepted by the current kernel wrapper but are ignored; restore is owned by the Rust session baseline.

update

Promise<void>
update(scenarioId: string, config: Partial<ScenarioConfig>): Promise<void>;
ParameterTypeRequired
scenarioIdstringrequired
configPartial<ScenarioConfig>required

Update an existing scenario's configuration. @param scenarioId - The scenario ID to update. @param config - Partial configuration with fields to change.

remove

Promise<void>
remove(id: string): Promise<void>;
ParameterTypeRequired
idstringrequired

Remove a scenario. @param id - The scenario ID to remove.