In SpreadJS versions prior to v17, the AutoSum option in the Designer ribbon may remain disabled when working with protected worksheets, even if the selected cells are unlocked.
This affects the following commands:
- FormulaAutoSum
- EditingAutoSum
The issue occurs when:
- Worksheet protection is enabled
- Editable ranges are configured using unlocked cells
sheet.options.isProtected = true;
sheet.getRange(row, col, rowCount, colCount).locked(false);
This behavior was resolved in SpreadJS v17.0.10. If upgrading is not possible, override the Designer command enableContext before initializing the Designer instance.
var formulaCmd = GC.Spread.Sheets.Designer.getCommand(
GC.Spread.Sheets.Designer.CommandNames.FormmulaAutoSum
);
formulaCmd.enableContext =
"(!IsIncludeLockedCell || !IsProtected) && " +
"!ChartSelected && !ShapeSelected && " +
"!pictureSelected && !SlicerSelected && " +
"!SelectedOrEditComments";
var editingAutoSumCmd = GC.Spread.Sheets.Designer.getCommand(
GC.Spread.Sheets.Designer.CommandNames.EditingAutoSum
);
editingAutoSumCmd.enableContext =
"(!IsIncludeLockedCell || !IsProtected) && " +
"!ChartSelected && !ShapeSelected && " +
"!pictureSelected && !SlicerSelected && " +
"!SelectedOrEditComments";
var config = GC.Spread.Sheets.Designer.DefaultConfig;
config.commandMap = {
formulaAutoSum: formulaCmd,
editingAutoSum: editingAutoSumCmd
};
let designer = new GC.Spread.Sheets.Designer.Designer("dss", config);
Kristina Ismail
Technical Engagement Engineer