How to copy Range from one worksheet to another worksheet?

I’m coping rows from one worksheet to another worksheet using the approach below.

it gives me option to choose starting row, ending row, starting column. However there is no option to select ending column. How do i copy range?

Workbook.Worksheets[1].Cells.CopyRows(
Workbook.Worksheets[0].Cells,
0, // source row Index
0, // destination row index
50); // number of rows to copy

Hi,

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

You can use Range.Copy() method for your needs. Please see the following code. It copies source range into destination range of another worksheet. I have also attached the source and destination workbooks for your reference.

C#


Workbook workbook = new Workbook(“source.xlsx”);


Worksheet srcSheet = workbook.Worksheets[0];

Worksheet destSheet = workbook.Worksheets[1];


//Source range to be copied

Range sourceRange = srcSheet.Cells.CreateRange(“A1:E5”);


//Destination range

Range destRange = destSheet.Cells.CreateRange(“F8:J12”);


//Copy the source range into destination range

destRange.Copy(sourceRange);


workbook.Save(“dest.xlsx”);

Thank you for help

this also fixed my other issue posted here
<a href="https://forum.aspose.com/t/86336

Hi,

Thanks for your posting and using Aspose.Cells.

It is good to know that your issue is resolved with the given code sample. If you encounter any other issue, please feel free to post on this forum. We will be glad to help you further.