DsExcel .NET provides users with the ability to cut or copy a cell or a range of cells from a specific area and paste it into another area within the same worksheet. You can also choose whether to copy and paste the data in a hidden range in a worksheet. To know more, refer to Paste or Skip Data in Invisible Range.
In order to cut or copy data across multiple sheets, refer to Cut or Copy Across Sheets.
DsExcel allows you to copy a cell or a range of cells in the worksheets by calling Copy method of IRange. To copy a single cell or a range of cells, specify the cell range to be copied, for example B3:D12.
DsExcel provides the following different ways to use the Copy method.
Example | Description |
---|---|
Copy(sheet.Range["E5"]) | This method copies data from cell range B3:D12 and pastes the data to cell E5 onwards. |
Copy(sheet.Range["E5:G14"]) | This method copies data from cell range B3:D12 and pastes the data in cell range E5:G14. In case the range of cells copied does not fit into the destination cell range, the data is lost. |
Refer to the following example code in order to copy the cell range in a workbook.
C# |
Copy Code |
---|---|
// Copy the data of the range of cells worksheet.Range["B3:D12"].Copy(worksheet.Range["E5"]); //Or worksheet.Range["B3:D12"].Copy(worksheet.Range["E5:G14"]); |
DsExcel allows you to cut a cell or a range of cells in the worksheet by calling the Cut method of the IRange interface. To cut a cell or the range of cells, specify the cell range to be moved, for example B3:D12.
DsExcel provide the following different ways to use Cut method.
Example | Description |
---|---|
Cut(sheet.Range["E5"]) | This method cuts the data from cell range B3:D12 and pastes the data to cell E5 onwards. |
Cut(sheet.Range["E5:G14"]) | This method cuts the data from cell range B3:D12 and pastes the data in cell range E5:G14. In case the range of cells cut does not fit into the destination cell range, the data is lost. |
Refer to the following example code to cut a range of cells in the workbook.
C# |
Copy Code |
---|---|
// Cut the data of the range of cell worksheet.Range["B3:D12"].Cut(worksheet.Range["E5"]); // Or worksheet.Range["B3:D12"].Cut(worksheet.Range["E5:G14"]); |