We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

How to copy a source row into several rows below and update references accordingly


I have a range of cells in one source row (not the entire row) which I need to copy into several rows below it (same range size). The source range of cells has a formula in each cell which I need updated (incremented) into the below ranges.

The way you would do this in excel would be to select a cell, then hold down the Shift key, scroll to the right to a cell in the same row as the previously selected cell, and then select that cell. Now you have a range of cells selected. If you go the the right-most cell in the selected range and hover the mouse over the lower right hand corner of that cell, you will see crosshairs. Once you see the crosshairs, click and hold the mouse and scroll down to cells below the originally selected range.

The result would be something like -
if a cell in the original selected range has a number “1” in it, the below cell would contain updated references. So the cell right below the original range would have a “2”, below that cell would be a “3” and so on.

I tried to do this in aspose using:

'Copy Formulas to newly added rows
sourceRange = currentSheet.Cells.CreateRange(cell.Row - 5, cell.Column, 1, 17)
Dim pasteOptions As New PasteOptions With {.PasteType = PasteType.All}
For count As Integer = 0 To numRowsAddedForReportSPConfig - 1
destinationRange = currentSheet.Cells.CreateRange((cell.Row - 3) + count, cell.Column, 1, 17)

- This copies the source data/formulas into the below rows (without updating any references)

- I also have tried:
currentSheet.Cells.InsertRange(cellArea, numRows, ShiftType.Down, True)

-cell area is source range

which does not copy any references and leaves the below inserted ranges blank

So, my question would be how do I do this in aspose

Any help would be greatly appreciated



Thanks for your posting and using Aspose.Cells for .NET.

Please refer to this article for your more help. The article explains how to copy Range object with Style information to some other destination Range.