[]
        
(Showing Draft Content)

GrapeCity.Documents.Excel.IScenario

IScenario Interface

A scenario is a group of input values (called changing cells) that's named and saved.

An IScenario represents a saved What-If analysis input set for a worksheet. It stores a scenario name together with the changing cells and can be shown, updated, hidden, locked, or deleted.

Namespace: GrapeCity.Documents.Excel
Assembly: DS.Documents.Excel.dll
Syntax
public interface IScenario
Public Interface IScenario
Examples
worksheet.Range["B2:B3"].Value = new object[,] {
    {100},
    {120}
};
IScenario scenario = worksheet.Scenarios.Add("Forecast", worksheet.Range["B2:B3"]);
scenario.Comment = "Projected sales inputs";

Properties

Name Description
ChangingCells

Gets a IRange object that represents the changing cells for the scenario.

Use the returned range to access the cells whose values are stored and applied by the scenario.

Comment

Gets or sets the comment text associated with the scenario.

Use this property to retrieve or update the descriptive text assigned to the scenario.

Hidden

Gets or sets whether the scenario is hidden.

This property indicates whether the scenario is marked as hidden.

Index

Returns the index of this scenario in the worksheet's scenario collection.

Use this property to get the scenario's position within the worksheet's scenario collection.

Locked

Gets or sets whether the scenario is locked.

A locked scenario is marked as protected from changes.

Name

Gets or sets the scenario name.

The returned value is the scenario name used to identify the scenario in the worksheet.

Values

Returns a list that contains the current values of the changing cells for the scenario.

Use Show() to apply these scenario values to the worksheet, or ChangingCells to retrieve the cells associated with the returned values.

Methods

Name Description
ChangeScenario(IRange, List<object>)

Changes the scenario to have a new set of changing cells and scenario values.

The values correspond to the cells in changingCells one by one. For example, if changingCells is "B2:C3", the values should be supplied in the order B2, C2, B3, and C3. If values is null, the current values in changingCells are used for the scenario.

Delete()

Deletes this scenario.

Use this method to remove a scenario that is no longer needed.

Show()

Applies the values saved in this scenario to the worksheet.

The affected cells are the changing cells of the scenario. This method replaces the current values in those cells with the values stored in the scenario. Formulas that reference the changing cells are recalculated when the calculation engine is enabled.