Copy Worksheets from one Workbook to another in Java

This article shows how to copy a worksheet from an Excel document to anther by using Spire.XLS for Java.

import com.spire.xls.Workbook;
import com.spire.xls.Worksheet;

public class CopySheetBetweenWorkbooks {
    public static void main(String[] args) {

        //Create a Workbook object to load the source document
        Workbook srcWorkbook = new Workbook();

        //Get the specific worksheet to copy
        Worksheet originalSheet = srcWorkbook.getWorksheets().get(0);

        //Create another Workbook object to load the destination document
        Workbook destWorkbook = new Workbook();

        //Add the copy of selected sheet to destination document
        Worksheet newSheet = destWorkbook.getWorksheets().addCopy(originalSheet);

        //Copy the theme of source document to destination document

        //Save to another file

Copy Worksheets from one Workbook to another in Java