Copy Rows

Hello,


I want to copy multiple rows from one workbook to another. But the documentation says I can copy only one row at a time. Is there any API to copy multiple rows from one Workbook to another?

Regards,
Jash

Hi Jash,


Thank you for contacting Aspose support.

You can use the Cells.copyRows method for your requirement. Please check the following piece of code that copies 32 rows from source spreadsheet to destination.

Java

Workbook sourcebook = new Workbook(“D:/book1.xlsx”);
Worksheet sourcesheet = sourcebook.getWorksheets().get(0);
Cells sourcecells = sourcesheet.getCells();

Workbook destbook = new Workbook();
Worksheet destsheet = destbook.getWorksheets().get(0);
Cells destcells = destsheet.getCells();

destcells.copyRows(sourcecells, 0, 0, 32);

destbook.save(“D:/copyrows.xlsx”);