Range Copy Question

Hello,

I have two open ASPOSE workbooks and I'd like to copy a range of cells from one to the other. For the first I have a range designation (e.g.: A10:C20), for the second I have a starting cell reference (e.g.: D15).

What's the recommended/best way to use the API to cause the cell contents to be copied from the first workbook to the other?

Thanks!

Hi,

Thanks for considering Aspose.

You can use Cells.CreateRange() method for creating range and Range.Copy() method to copy one range to other for your desired results.

Kindly utilize the following sample code:

Workbook source = new Workbook();

source.Open(@"d:\bk1.xls");

Range r1 = source.Worksheets[0].Cells.CreateRange("A10","C20");

Workbook target = new Workbook();

Range r2 = target.Worksheets[0].Cells.CreateRange("D15","F25");

r2.Copy(r1);

target.Save(@"d:\testrange.xls");

Regards

Amjad Sahi

Aspose Nanjing Team