Hi,
Thanks for the detailed questions — I’ll go through each one.
Is there a global/workbook-level theme that new sheets automatically inherit?
No. In SpreadJS, theming and styling properties (currentTheme, gridline color, selection colors, header styles, default cell style) all live on the Worksheet object, not the Workbook. There isn’t a workbook-level setting that automatically cascades into sheets created after it’s set.
Recommended pattern to avoid manually reapplying the same configuration
The approach we recommend is to centralize your styling in one function, then trigger it automatically from the SheetChanged event at the workbook level. This event fires for every sheet insertion — whether the sheet is added through your code or by the end user clicking the “+” tab — so once it’s wired up, you never have to call it manually again:
function applyWorkbookTheme(sheet) {
sheet.currentTheme('YourCustomTheme');
sheet.options.gridline = { color: '#c0c0c0', showHorizontalGridline: true, showVerticalGridline: true };
sheet.options.selectionBackColor = '#d6e4ff';
sheet.options.selectionBorderColor = '#4472c4';
const cellDefault = new GC.Spread.Sheets.Style();
cellDefault.font = '10pt Segoe UI';
sheet.setDefaultStyle(cellDefault, GC.Spread.Sheets.SheetArea.viewport);
const headerDefault = new GC.Spread.Sheets.Style();
headerDefault.backColor = '#2f4f6f';
headerDefault.foreColor = '#ffffff';
sheet.setDefaultStyle(headerDefault, GC.Spread.Sheets.SheetArea.colHeader);
sheet.setDefaultStyle(headerDefault, GC.Spread.Sheets.SheetArea.rowHeader);
}
// Bind once, at the workbook level
spread.bind(GC.Spread.Sheets.Events.SheetChanged, function (sender, args) {
if (args.propertyName === 'insertSheet') {
applyWorkbookTheme(spread.getSheet(args.sheetIndex));
}
});
Workbook-level defaults for the specific properties you asked about
Gridline color: sheet.options.gridline — per-sheet only
Row/column header style: sheet.setDefaultStyle(style, SheetArea.colHeader / rowHeader), or options.colHeaderBackColor / rowHeaderBackColor — per-sheet only
Default cell style: sheet.setDefaultStyle(style, SheetArea.viewport) — per-sheet only
Selection background/border color: sheet.options.selectionBackColor / selectionBorderColor — per-sheet only
Selection color of corresponding headers: this one is actually not a per-sheet JS property at all — it’s controlled by CSS classes on the page (.gc-columnHeader-selected / .gc-rowHeader-selected for a fully selected column/row, .gc-columnHeader-highlight / .gc-rowHeader-highlight when some cells in that column/row are selected, plus the -hover and -normal variants). Because these are just stylesheet rules, they apply globally across every sheet and every workbook on the page automatically — no per-sheet code needed.
Everything else (frozen line color, header auto-text, etc.): sheet.options.* — per-sheet only
Is iterating through all sheets the best-practice approach performance-wise?
For sheets that already exist (on load, or when bulk-creating many sheets), yes — there’s no bulk/global setter, so iterating is necessary. It performs well as long as you:
Wrap the entire loop in spread.suspendPaint() / spread.resumePaint(), calling each once outside the loop rather than per sheet
Use setDefaultStyle/options assignment rather than looping over individual cells — cost scales with the number of sheets, not the number of cells, so this stays fast even with a large sheet count
Reuse a single Style/Theme instance rather than constructing a new one inside the loop
spread.suspendPaint();
spread.suspendEvent();
try {
for (let i = 0; i < spread.getSheetCount(); i++) {
applyWorkbookTheme(spread.getSheet(i));
}
} finally {
spread.resumeEvent();
spread.resumePaint();
}
Best regards,
Priyam