Articles in this section
Category / Section

How to restrict paste to "Paste Values" only in Spreadsheet?

1 min read

This knowledge base explains how to restrict the paste action to the Paste Values only in the JavaScript Spreadsheet. It is achievable by setting the “type” argument as Values in the client side ‘actionBegin event. It restricts the paste operation to paste values only in the cells for all possibilities of paste actions in the Spreadsheet.

 

[HTML]

<div id="spreadsheet"></div>

 

[TS]

//Initialize the Spreadsheet component.
let spreadsheet: Spreadsheet = new Spreadsheet({
  sheets: [
    {
      name: 'Car Sales Report',
      ranges: [{ dataSource: (dataSource as any).defaultData }],
      columns: [
        { width: 180 },
        { width: 130 },
        { width: 130 },
        { width: 180 },
        { width: 130 },
        { width: 120 },
      ],
    },
  ],
  created: (): void => {
    //Apply cell and number formatting to a specified range of the active sheet.
    spreadsheet.cellFormat(
      { fontWeight: 'bold', textAlign: 'center', verticalAlign: 'middle' },
      'A1:F1'
    );
    spreadsheet.numberFormat('$#,##0.00', 'F2:F31');
},
  actionBegin: (args): void => {
    if (args.args.eventArgs && args.args.eventArgs.requestType == 'paste') {
      args.args.eventArgs.type = 'Values'; // It paste only values for all type of paste actions like within sheet and external paste.
    }
  },
});
 

 

Sample Link: https://stackblitz.com/edit/tud9n7?file=index.ts

 

Documentation Link:

 

https://ej2.syncfusion.com/documentation/spreadsheet/clipboard/

 

 

Conclusion

I hope you enjoyed learning about ow to restrict paste to "Paste Values" only in Spreadsheet.

You can refer to our JavaScript Spreadsheet feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications. You can also explore our JavaScript Spreadsheet example to understand how to create and manipulate data.

For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.

If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forumsDirect-Trac, or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied