This is a migrated thread and some comments may be shown as answers.

How to move Cell's values?

1 Answer 61 Views
SpreadProcessing
This is a migrated thread and some comments may be shown as answers.
MAE
Top achievements
Rank 1
MAE asked on 29 Oct 2016, 01:34 AM
For example if I have a CellSelection coordinates how can I retrieve the values from all cells and move it like a cut and paste text in another part of my export excel file? 

1 Answer, 1 is accepted

Sort by
0
Boby
Telerik team
answered on 01 Nov 2016, 06:30 AM
Hello Mae,

I guess the question here is the same as in the other forum thread you started in the WPF forum here. I will post the sample code for cut/paste here also for clarity:
using (new UpdateScope(workbook.History.BeginUndoGroup, workbook.History.EndUndoGroup))
{
    CellRange copiedCellRange = new CellRange(0, 0, 2, 1);
    WorksheetFragment worksheetFragment = worksheet.Cells[copiedCellRange].Copy();
    worksheet.Cells[copiedCellRange].Clear(ClearType.All);
    worksheet.Cells[3, 3, 5, 4].Paste(worksheetFragment, new PasteOptions(PasteType.All));
}

If you do not need history, you can disable it using workbook.History.IsEnabled property and skip the using (new UpdateScope(workbook.History.BeginUndoGroup, workbook.History.EndUndoGroup)) part. This can improve your performance and memory consumption, especially if you are moving large fragments around.

Regards,
Boby
Telerik by Progress

Tags
SpreadProcessing
Asked by
MAE
Top achievements
Rank 1
Answers by
Boby
Telerik team
Share this question
or