How Do I Fill Down CTRL+D

Posted by: jeff on 27 November 2020, 12:57 pm EST

  • Posted 27 November 2020, 12:57 pm EST

  • Posted 30 November 2020, 11:55 pm EST

    Hi Jeff,

    You may create your own custom command which performs the fill down on ctrl+D. Please refer to the following g code snippet and attached sample that demonstrates the same.

    
     var command = {
        canUndo: true,
        execute: function (spread, options, isUndo) {
          var Commands = GC.Spread.Sheets.Commands;
          if (isUndo) {
            Commands.undoTransaction(spread, options);
            return true;
          } else {
            Commands.startTransaction(spread, options);
            spread.suspendPaint();
            let selections = spread.getActiveSheet().getSelections();
            options.cmd = "ctrlFill";
            selections.forEach((sel) => {
              let srange = new GC.Spread.Sheets.Range(
                sel.row,
                sel.col,
                1,
                sel.colCount
              );
              let drange = new GC.Spread.Sheets.Range(
                sel.row + 1,
                sel.col,
                sel.rowCount - 1,
                sel.colCount
              );
    
              spread.commandManager().execute({
                cmd: "fill",
                sheetName: spread.getActiveSheet().name(),
                startRange: srange,
                fillRange: drange,
                autoFillType: GC.Spread.Sheets.Fill.AutoFillType.fillSeries,
                fillDirection: GC.Spread.Sheets.Fill.FillDirection.down
              });
            });
            spread.resumePaint();
            Commands.endTransaction(spread, options);
            return true;
          }
        }
    
    ```0
    
    sample:  https://codesandbox.io/s/lucid-raman-1ydsm?file=/src/index.js:190-1432
    
    API Reference:
    Custom Commands Demo: https://www.grapecity.com/spreadjs/demos/features/worksheet/actions/custom-action#demo_source_name
    
    Regards
    Avinash
Need extra support?

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

Learn More

Forum Channels