Skip to main content

Posts

Showing posts with the label excel

Copy Data From One Excel To Another Using Apache POI

In case there is a requirement where you need to copy the data from one excel file into another excel using test automation, we can use Apache POI open-source library to do that. Here's the self-explanatory code but do let me know if you have any queries. For other details, you can go through https://www.javatpoint.com/apache-poi-tutorial import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.util.Iterator; import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.Row; import org.apache.poi.xssf.usermodel.XSSFSheet; import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.testng.annotations.Test; public class CopyExcel { @Test public static void CopyOneWBookToOther() throws IOException { // Step #1 : Locate path and file name of target and output excel. String TargetSheetPathAndName = "/Users/dheerajgambhir/Desktop/O