Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 65 additions & 5 deletions Document-Processing/Excel/Spreadsheet/React/clipboard.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ documentation: ug

# Clipboard in React Spreadsheet component

The Spreadsheet provides support for the clipboard operations (cut, copy, and paste). Clipboard operations can be enabled or disabled by setting the [`enableClipboard`](https://ej2.syncfusion.com/react/documentation/api/spreadsheet/#enableclipboard) property in Spreadsheet.
The Spreadsheet provides support for the clipboard operations (cut, copy, and paste). Clipboard operations can be enabled or disabled by setting the [`enableClipboard`](https://ej2.syncfusion.com/react/documentation/api/spreadsheet#enableclipboard) property in Spreadsheet.

> By default, the `enableClipboard` property is true.

Expand All @@ -24,7 +24,7 @@ Cut can be done in one of the following ways.
* Using Cut button in the Ribbon’s HOME tab to perform cut operation.
* Using Cut option in the Context Menu.
* Using `Ctrl + X` | `Command + X` keyboard shortcut.
* Using the [`cut`](https://ej2.syncfusion.com/react/documentation/api/spreadsheet/#cut) method.
* Using the [`cut`](https://ej2.syncfusion.com/react/documentation/api/spreadsheet#cut) method.

## Copy

Expand All @@ -37,7 +37,7 @@ Copy can be done in one of the following ways.
* Using Copy button in the Ribbon’s HOME tab to perform copy operation.
* Using Copy option in the Context Menu.
* Using `Ctrl + C` | `Command + C` keyboard shortcut.
* Using the [`copy`](https://ej2.syncfusion.com/react/documentation/api/spreadsheet/#copy) method.
* Using the [`copy`](https://ej2.syncfusion.com/react/documentation/api/spreadsheet#copy) method.

## Paste

Expand All @@ -55,7 +55,7 @@ Paste can be done in one of the following ways.
* Using Paste button in the Ribbon’s HOME tab to perform paste operation.
* Using Paste option in the Context Menu.
* Using `Ctrl + V` | `Command + V` keyboard shortcut.
* Using the [`paste`](https://ej2.syncfusion.com/react/documentation/api/spreadsheet/#paste) method.
* Using the [`paste`](https://ej2.syncfusion.com/react/documentation/api/spreadsheet#paste) method.

> If you use the Keyboard shortcut key for cut (`Ctrl + X`) / copy (`Ctrl + C`) from other sources, you should use `Ctrl + V` shortcut while pasting into the spreadsheet.

Expand All @@ -78,7 +78,7 @@ Paste can be done in one of the following ways.

## Prevent the paste functionality

The following example shows, how to prevent the paste action in spreadsheet. In [`actionBegin`](https://ej2.syncfusion.com/react/documentation/api/spreadsheet/#actionbegin) event, you can set `cancel` argument as false in paste request type.
The following example shows, how to prevent the paste action in spreadsheet. In [`actionBegin`](https://ej2.syncfusion.com/react/documentation/api/spreadsheet#actionbegin) event, you can set `cancel` argument as false in paste request type.

{% tabs %}
{% highlight js tabtitle="app.jsx" %}
Expand All @@ -97,6 +97,66 @@ The following example shows, how to prevent the paste action in spreadsheet. In

{% previewsample "/document-processing/code-snippet/spreadsheet/react/clipboard-cs2" %}

## Events triggered during clipboard operations

When performing clipboard operations such as **Cut**, **Copy**, or **Paste**, the spreadsheet triggers specific events that allow users to monitor and manage these actions effectively. The following sections outline the event sequence and their roles.

**Cut / Copy**

For **Cut** or **Copy** actions, only the [`actionBegin`](https://ej2.syncfusion.com/react/documentation/api/spreadsheet/index-default#actionbegin) event is triggered. You can identify the type of action and access the copied range using the following properties:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove 'only'


* `args.action === 'cut'` → Indicates a Cut action
* `args.action === 'copy'` → Indicates a Copy action
* `args.args.copiedRange` → Provides the copied range
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Provides the copy or cut range


**Paste**

During a **Paste** operation, events are triggered in the following sequence:

> actionBegin → beforeCellUpdate → cellSave → actionComplete

The table below describes each event and its role in the paste process:

| Event | Description |
|-------------------|---------------------------------------------------------------------------------------------|
| [`actionBegin`](https://ej2.syncfusion.com/react/documentation/api/spreadsheet/index-default#actionbegin) | Triggers when the paste action starts. |
| [`beforeCellUpdate`](https://ej2.syncfusion.com/react/documentation/api/spreadsheet/index-default#beforecellupdate) | Triggers for each cell in the pasted range before its properties are updated. |
| [`cellSave`](https://ej2.syncfusion.com/react/documentation/api/spreadsheet/index-default#cellsave) | Triggers for each cell in the pasted range after the updated cell is saved. |
| [`actionComplete`](https://ej2.syncfusion.com/react/documentation/api/spreadsheet/index-default#actioncomplete) | Triggers once all pasted cells are processed. |

The following code example showcases the events triggered during clipboard operations in spreadsheet.

{% tabs %}
{% highlight js tabtitle="app.jsx" %}
{% include code-snippet/spreadsheet/react/clipboard-cs3/app/app.jsx %}
{% endhighlight %}
{% highlight ts tabtitle="app.tsx" %}
{% include code-snippet/spreadsheet/react/clipboard-cs3/app/app.tsx %}
{% endhighlight %}
{% highlight js tabtitle="datasource.jsx" %}
{% include code-snippet/spreadsheet/react/clipboard-cs3/app/datasource.jsx %}
{% endhighlight %}
{% highlight ts tabtitle="datasource.tsx" %}
{% include code-snippet/spreadsheet/react/clipboard-cs3/app/datasource.tsx %}
{% endhighlight %}
{% endtabs %}

{% previewsample "/document-processing/code-snippet/spreadsheet/react/clipboard-cs3" %}

> **Note**: The events [cellEdit](https://ej2.syncfusion.com/react/documentation/api/spreadsheet/index-default#celledit), [cellEditing](https://ej2.syncfusion.com/react/documentation/api/spreadsheet/index-default#cellediting), and [beforeCellSave](https://ej2.syncfusion.com/react/documentation/api/spreadsheet/index-default#beforecellsave) are not triggered during clipboard operations. These events are specific to manual cell edits. However, [beforeCellUpdate](https://ej2.syncfusion.com/react/documentation/api/spreadsheet/index-default#beforecellupdate) is triggered for each cell update before any property is changed, including during paste actions.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this


**Accessing clipboard properties**

You can access clipboard-related properties such as the copied and pasted ranges during paste operations using the [`actionBegin`](https://ej2.syncfusion.com/react/documentation/api/spreadsheet/index-default#actionbegin) and [`actionComplete`](https://ej2.syncfusion.com/react/documentation/api/spreadsheet/index-default#actioncomplete) events. Ensure the action and request type using:

* `args.action === 'clipboard'`
* `args.eventArgs.requestType === 'paste'`

Once confirmed, you can access the following properties:

* `args.eventArgs.copiedRange`
* `args.eventArgs.pastedRange`

## Limitations

* External clipboard is not fully supported while copying data from another source and pasting into a spreadsheet, it only works with basic supports (Values, Number, cell, and Text formatting).
Expand Down
49 changes: 44 additions & 5 deletions Document-Processing/Excel/Spreadsheet/React/editing.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ documentation: ug

# Editing in React Spreadsheet component

You can edit the contents of a cell directly in the cell or by typing in the formula bar. By default, the editing feature is enabled in the spreadsheet. Use the [`allowEditing`](https://ej2.syncfusion.com/react/documentation/api/spreadsheet/#allowediting) property to enable or disable the editing feature.
You can edit the contents of a cell directly in the cell or by typing in the formula bar. By default, the editing feature is enabled in the spreadsheet. Use the [`allowEditing`](https://ej2.syncfusion.com/react/documentation/api/spreadsheet#allowediting) property to enable or disable the editing feature.

To get start quickly with Editing, you can check on this video:

Expand All @@ -23,24 +23,24 @@ You can start editing by one of the following ways,
* Press `F2` key to edit the active cell.
* Use formula bar to perform editing.
* Use `BACKSPACE` or `SPACE` key to clear the cell content and start the edit mode.
* Using the [`startEdit`](https://ej2.syncfusion.com/react/documentation/api/spreadsheet/#startedit) method.
* Using the [`startEdit`](https://ej2.syncfusion.com/react/documentation/api/spreadsheet#startedit) method.

## Save cell

If the cell is in editable state, you can save the edited cell by one of the following ways,

* Perform mouse click on any other cell rather than the current editing cell.
* Press `Enter` or `Tab` keys to save the edited cell content.
* Using the [`endEdit`](https://ej2.syncfusion.com/react/documentation/api/spreadsheet/#endedit) method.
* Using the [`endEdit`](https://ej2.syncfusion.com/react/documentation/api/spreadsheet#endedit) method.

## Cancel editing

To cancel the editing without saving the changes, you can use one of the following ways,

* Press `ESCAPE` key, this will remove the editable state and update the unchanged cell content.
* Using the [`closeEdit`](https://ej2.syncfusion.com/react/documentation/api/spreadsheet/#closeedit) method.
* Using the [`closeEdit`](https://ej2.syncfusion.com/react/documentation/api/spreadsheet#closeedit) method.

The following sample shows how to prevent the editing and cell save. Here `E` column prevent the editing by using cancel argument as true in [`cellEdit`](https://ej2.syncfusion.com/react/documentation/api/spreadsheet/#celledit) event. In `D` column, prevent saving the edited changes by using cancel argument as true in [`beforeCellSave`](https://ej2.syncfusion.com/react/documentation/api/spreadsheet/#beforecellsave) and use [`closeEdit`](https://ej2.syncfusion.com/react/documentation/api/spreadsheet/#closeedit) method in spreadsheet.
The following sample shows how to prevent the editing and cell save. Here `E` column prevent the editing by using cancel argument as true in [`cellEdit`](https://ej2.syncfusion.com/react/documentation/api/spreadsheet#celledit) event. In `D` column, prevent saving the edited changes by using cancel argument as true in [`beforeCellSave`](https://ej2.syncfusion.com/react/documentation/api/spreadsheet#beforecellsave) and use [`closeEdit`](https://ej2.syncfusion.com/react/documentation/api/spreadsheet#closeedit) method in spreadsheet.

{% tabs %}
{% highlight js tabtitle="app.jsx" %}
Expand All @@ -59,6 +59,45 @@ The following sample shows how to prevent the editing and cell save. Here `E` co

{% previewsample "/document-processing/code-snippet/spreadsheet/react/editing-cs1" %}

## Events triggered during cell editing

When a cell is edited manually—such as by **double-clicking the cell**, **pressing the F2 key**, or **modifying it through the formula bar**—the spreadsheet triggers a series of events. These events allow users to monitor and manage the entire editing process, from initiation to completion.

The sequence of events during manual cell editing is:
> cellEdit → cellEditing → actionBegin → beforeCellUpdate → beforeCellSave → cellSave / cellEdited → actionComplete

The table below lists each event and its role in the editing process:

| Event | Description |
|------------------------|---------------------------------------------------------------------------------------------|
| [`cellEdit`](https://ej2.syncfusion.com/react/documentation/api/spreadsheet/index-default#celledit) | Triggers before the cell enters edit mode. |
| [`cellEditing`](https://ej2.syncfusion.com/react/documentation/api/spreadsheet/index-default#cellediting) | Triggers while editing is in progress; fires for each change made to the cell content. |
| [`actionBegin`](https://ej2.syncfusion.com/react/documentation/api/spreadsheet/index-default#actionbegin) | Triggers when the edit action starts. |
| [`beforeCellUpdate`](https://ej2.syncfusion.com/react/documentation/api/spreadsheet/index-default#beforecellupdate) | Triggers before any cell property (style, value, formula, etc.) is modified. |
| [`beforeCellSave`](https://ej2.syncfusion.com/react/documentation/api/spreadsheet/index-default#beforecellsave) | Triggers before the cell value is saved. |
| [`cellSave` ](https://ej2.syncfusion.com/react/documentation/api/spreadsheet/index-default#cellsave) | Triggers when the cell value is saved. |
| [`cellEdited`](https://ej2.syncfusion.com/react/documentation/api/spreadsheet/index-default#celledited) | Triggers after the editing process completes. |
| [`actionComplete`](https://ej2.syncfusion.com/react/documentation/api/spreadsheet/index-default#actioncomplete) | Triggers once the entire edit operation is completed. |

The following code example showcases the events triggered during cell edting in spreadsheet.

{% tabs %}
{% highlight js tabtitle="app.jsx" %}
{% include code-snippet/spreadsheet/react/editing-cs2/app/app.jsx %}
{% endhighlight %}
{% highlight ts tabtitle="app.tsx" %}
{% include code-snippet/spreadsheet/react/editing-cs2/app/app.tsx %}
{% endhighlight %}
{% highlight js tabtitle="datasource.jsx" %}
{% include code-snippet/spreadsheet/react/editing-cs2/app/datasource.jsx %}
{% endhighlight %}
{% highlight ts tabtitle="datasource.tsx" %}
{% include code-snippet/spreadsheet/react/editing-cs2/app/datasource.tsx %}
{% endhighlight %}
{% endtabs %}

{% previewsample "/document-processing/code-snippet/spreadsheet/react/editing-cs2" %}

## Limitations

* Text overflow in cells is not supported in Editing.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import * as React from 'react';
import { createRoot } from 'react-dom/client';
import { SpreadsheetComponent, SheetsDirective, SheetDirective, RangesDirective } from '@syncfusion/ej2-react-spreadsheet';
import { RangeDirective, ColumnsDirective, ColumnDirective } from '@syncfusion/ej2-react-spreadsheet';
import { data } from './datasource';

function App() {
let spreadsheet;
const spreadsheetRef = React.useRef(null);

const onCreated = () => {
spreadsheet = spreadsheetRef.current;
spreadsheet.cellFormat({ backgroundColor: '#357cd2', color: '#fff', fontWeight: 'bold', textAlign: 'center' }, 'A1:H1');
}

const actionBegin = (args) => {
console.log('actionBegin triggered');
}

const beforeCellSave = (args) => {
console.log('beforeCellSave triggered')
}

const beforeCellUpdate = (args) => {
console.log('beforeCellUpdate triggered');
}

const cellEdit = (args) => {
console.log('cellEdit triggered');
}

const cellEditing = (args) => {
console.log('cellEditing triggered')
}

const cellEdited = (args) => {
console.log('cellEdited triggered');
}

const cellSave = (args) => {
console.log('cellSave triggered')
}

const actionComplete = (args) => {
console.log('actionComplete triggered');
}

return (
<div>
<SpreadsheetComponent ref={spreadsheetRef} created={onCreated} actionBegin={actionBegin} beforeCellSave={beforeCellSave} beforeCellUpdate={beforeCellUpdate} cellSave={cellSave} cellEdit={cellEdit} cellEditing={cellEditing} cellEdited={cellEdited} actionComplete={actionComplete} >
<SheetsDirective>
<SheetDirective>
<RangesDirective>
<RangeDirective dataSource={data}></RangeDirective>
</RangesDirective>
<ColumnsDirective>
<ColumnDirective width={130}></ColumnDirective>
<ColumnDirective width={100}></ColumnDirective>
<ColumnDirective width={100}></ColumnDirective>
</ColumnsDirective>
</SheetDirective>
</SheetsDirective>
</SpreadsheetComponent>
</div>
);
};
export default App;

const root = createRoot(document.getElementById('root'));
root.render(<App />);
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import * as React from 'react';
import { createRoot } from 'react-dom/client';
import { SpreadsheetComponent, SheetsDirective, SheetDirective, RangesDirective } from '@syncfusion/ej2-react-spreadsheet';
import { RangeDirective, ColumnsDirective, ColumnDirective } from '@syncfusion/ej2-react-spreadsheet';
import { data } from './datasource';

function App() {
let spreadsheet: SpreadsheetComponent;
const spreadsheetRef = React.useRef<SpreadsheetComponent>(null);
const onCreated = () => {
spreadsheet = spreadsheetRef.current;
spreadsheet.cellFormat({ backgroundColor: '#357cd2', color: '#fff', fontWeight: 'bold', textAlign: 'center' }, 'A1:H1');
}

const actionBegin = (args) => {
console.log('actionBegin triggered');
}

const beforeCellSave = (args) => {
console.log('beforeCellSave triggered')
}

const beforeCellUpdate = (args) => {
console.log('beforeCellUpdate triggered');
}

const cellEdit = (args) => {
console.log('cellEdit triggered');
}

const cellEditing = (args) => {
console.log('cellEditing triggered')
}

const cellEdited = (args) => {
console.log('cellEdited triggered');
}

const cellSave = (args) => {
console.log('cellSave triggered')
}

const actionComplete = (args) => {
console.log('actionComplete triggered');
}

return (
<div>
<SpreadsheetComponent ref={spreadsheetRef} created={onCreated} actionBegin={actionBegin} beforeCellSave={beforeCellSave} beforeCellUpdate={beforeCellUpdate} cellSave={cellSave} cellEdit={cellEdit} cellEditing={cellEditing} cellEdited={cellEdited} actionComplete={actionComplete} >
<SheetsDirective>
<SheetDirective>
<RangesDirective>
<RangeDirective dataSource={data}></RangeDirective>
</RangesDirective>
<ColumnsDirective>
<ColumnDirective width={130}></ColumnDirective>
<ColumnDirective width={100}></ColumnDirective>
<ColumnDirective width={100}></ColumnDirective>
</ColumnsDirective>
</SheetDirective>
</SheetsDirective>
</SpreadsheetComponent>
</div>
);
};
export default App;

const root = createRoot(document.getElementById('root')!);
root.render(<App />);
Loading