DEV Community

loading...

Copy Excel Range to Worksheet in Java

asposecells profile image AsposeCells Updated on ・3 min read

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 in their applications to copy Excel range to same worksheet or different worksheet.

Aspose.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.

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.

The following screenshot shows the sample Excel file used inside the code and the output Excel file generated by the code 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

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.

The following screenshot shows the sample Excel file used inside the code and the output Excel file generated by the code 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

See also

Discussion (0)

pic
Editor guide