Copy Excel Range to Worksheet in C++
Tags: copyrange, excel, aspose, cpp
Published: 2018-09-25 07:40:18

---
title: Copy Excel Range to Worksheet in C++
published: true
description: Copy Excel Range to Worksheet in C++
tags: #CopyRange #Excel #Aspose #CPP
---
Microsoft Excel Range can contain a single cell or multiple cells. It has a start cell and end cell. All the cells that lie within start cell and end cell constitutes a range. Sometimes, user wants to copy a range of cells to some other location inside the same worksheet or to some other location inside the different worksheet.

The purpose of this article is to explain how the C++ developers or programmers can use [Aspose.Cells](https://products.aspose.com/cells/cpp) in their applications to copy Excel range to same worksheet or different worksheet.

>[Aspose.Cells](https://products.aspose.com/cells/) API supports number of platform e.g. .NET, Java, C++, Android, JavaScript, PHP etc. Besides, [Aspose.Cells is available in Cloud as RESTful APIs](https://products.aspose.cloud/cells).


# Copy Excel Range to Same Worksheet

The following C++ sample code loads the sample Excel file inside the Aspose.Cells Workbook object. It then accesses the first worksheet which contains the source Excel range that we want to copy to same worksheet. It then uses the ***Range.Copy()*** method to copy it to new location inside the worksheet.

{% gist https://gist.github.com/AsposeCells/2f8f092fcd0e60b55b1e01d08a313f69 %}

The following [screenshot](https://github.com/AsposeCells/AsposeCells-Screenshots-and-Sample-Files/blob/master/Copy-Excel-Range-to-Worksheet/Excel-Range-copied-to-different-location-inside-the-Same-Worksheet-using-Aspose.Cells-API.png) shows the [sample Excel file used inside the code](https://github.com/AsposeCells/AsposeCells-Screenshots-and-Sample-Files/blob/master/Copy-Excel-Range-to-Worksheet/sampleExcelRange.xlsx) and the [output Excel file generated by the code](https://github.com/AsposeCells/AsposeCells-Screenshots-and-Sample-Files/blob/master/Copy-Excel-Range-to-Worksheet/outputCopyExcelRangeToSameWorksheet.xlsx) for your reference. As you can see inside the screenshot, ***the source Excel range has been copied to the destination Excel range.***

>_**Caption:** Excel Range copied to different location inside the Same Worksheet using Aspose.Cells API_

![Excel Range copied to different location inside the Same Worksheet using Aspose.Cells API](https://raw.githubusercontent.com/AsposeCells/AsposeCells-Screenshots-and-Sample-Files/master/Copy-Excel-Range-to-Worksheet/Excel-Range-copied-to-different-location-inside-the-Same-Worksheet-using-Aspose.Cells-API.png "Excel Range copied to different location inside the Same Worksheet using Aspose.Cells API")

# Copy Excel Range to Different Worksheet

The following C++ sample code loads the sample Excel file inside the Aspose.Cells Workbook object. It accesses the first worksheet which contains the source Excel range and the second worksheet where source range is to be copied. It then copies source range of first worksheet into destination range inside second worksheet using the _**Range.Copy()**_ method.

{% gist https://gist.github.com/AsposeCells/1eb734b480ca9360bf78581e9488a79a %}

The following [screenshot](https://github.com/AsposeCells/AsposeCells-Screenshots-and-Sample-Files/blob/master/Copy-Excel-Range-to-Worksheet/Excel-Range-copied-to-Different-Worksheet-using-Aspose.Cells-API.png) shows the [sample Excel file used inside the code](https://github.com/AsposeCells/AsposeCells-Screenshots-and-Sample-Files/blob/master/Copy-Excel-Range-to-Worksheet/sampleExcelRange.xlsx) and the [output Excel file generated by the code](https://github.com/AsposeCells/AsposeCells-Screenshots-and-Sample-Files/blob/master/Copy-Excel-Range-to-Worksheet/outputCopyExcelRangeToDifferentWorksheet.xlsx) for your reference. As you can see inside the screenshot, _**the source Excel range has been copied to the destination Excel range in different worksheet.**_

>_**Caption:** Excel Range copied to Different Worksheet using Aspose.Cells API_

![Excel Range copied to Different Worksheet using Aspose.Cells API](https://raw.githubusercontent.com/AsposeCells/AsposeCells-Screenshots-and-Sample-Files/master/Copy-Excel-Range-to-Worksheet/Excel-Range-copied-to-Different-Worksheet-using-Aspose.Cells-API.png "Excel Range copied to Different Worksheet using Aspose.Cells API")

# See also

* [Copy Excel Range to Worksheet in C#](https://dev.to/asposecells/copy-excel-range-to-worksheet-in-c-3om4)
* [Create Named Range in a Workbook](https://docs.aspose.com/display/cellscpp/Create+Named+Range+in+a+Workbook)
* [Forum -  Aspose.Cells Product Family](https://forums.aspose.com/c/cells)