Posted 25 March 2024, 1:31 am EST
I am trying to add a button to the spreadsheet toolbar that will clear the whole sheet when clicked but I’m having no luck. Below is the code I have so far but it doesn’t seem to do anything. Any help would be most appreciated.
export function addResetButton(config) {
config.commandMap = {
cmdResetSpreadsheet: {
title: 'Reset Spreadsheet',
text: '',
type: 'button',
iconClass: 'cmdResetSpreadsheet',
bigButton: false,
commandName: 'cmdResetSpreadsheet',
execute: async () => {
const spread = new GC.Spread.Sheets.Workbook();
const sheet = spread.getActiveSheet();
sheet.clear(
0,
0,
sheet.getRowCount(),
sheet.getColumnCount(),
GC.Spread.Sheets.SheetArea.viewport,
GC.Spread.Sheets.StorageType.data,
);
},
},
};
}