[]
GcExcel .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.
GcExcel 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.
GcExcel 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.
// 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"]);
GcExcel 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.
GcExcel 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.
// 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"]);