Copy Excel Range to Worksheet in Java
Tags: copyrange, excel, aspose, java
Published: 2018-09-25 07:39:28

---
title: Copy Excel Range to Worksheet in Java
published: true
description: Copy Excel Range to Worksheet in Java
tags: #CopyRange #Excel #Aspose #Java
---
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 Java developers or programmers can use [Aspose.Cells](https://products.aspose.com/cells/java) 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 REST or RESTful APIs](https://products.aspose.cloud/cells).


# Copy Excel Range to Same Worksheet

The following Java 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/f700220ee76ae581164eb90462c21bde %}

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 Java 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/ace6e2ec82dc7649c5d5261d2bb0bf9b %}

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-4an4)
* [Copy Range Data with Style](https://docs.aspose.com/display/cellsjava/Copy+Range+Data+with+Style)
* [Copy Range Data Only](https://docs.aspose.com/display/cellsjava/Copy+Range+Data+Only)
* [Forum -  Aspose.Cells Product Family](https://forums.aspose.com/c/cells)