How do I clear a worksheet from a custom toolbar button?

Posted by: alex.grant1 on 25 March 2024, 1:31 am EST

  • 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,
            );
          },
        },
      };
    }
  • Posted 26 March 2024, 4:43 pm EST

    Hi,

    I think Chandan has already provided the solution on the following Forum Case created by you: https://developer.mescius.com/forums/spreadjs/how-do-i-clear-a-spreadsheet-programmatically

    I hope that clarifies the issue you are facing. Kindly do let us know on the mentioned Forum case if you still have the issue.

    Regards,

    Ankit

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels