Copy Data From One Excel To Another Using Selenium WebDriver


Copy Data From One Excel To Another Using Selenium WebDriver


As we all are aware reading and writing data from excel file is one of the most important aspects that we need to take care while designing our automation testing framework

Sometime During designing our test automation framework specially while using the data-driven testing approach we came across requirements where we need to copy the data from one excel file and paste it into another excel using test automation.




so in this Section, we will learn how we copy-paste the data from one excel file to another excel file.

Apache POI API is an open-source library created by Apache Software that allows us to create, modify and work with other Microsoft Office Product.

To know more about the Apache POI API and its components. Please refer to this link.

To start working we first need to download Apache POI maven dependency or JAR. Please click on this link to download this from the maven repository.

In this Section, I am using below maven dependencies.



For Demo purpose, I have created below excel sheet named as Test Data 1 and kept it on my Desktop.


Test Data 1.xlsx

And all the data from this excel sheet I will do copy paste into another excel named as Test Data 2 which is again placed on my desktop




Below is the complete code snippet. All the important points are mentioned in the code itself which is very much self-explanatory.



Result of above code execution is

Eclipse Console Output

Test Data 2.Xlsx




SHARE THIS

Author:

My Name is Ankur Jain and I am currently working as Automation Test Architect.I am ISTQB Certified Test Manager,Certified UI Path RPA Developer as well as Certified Scrum Master with total 12 years of working experience with lot of big banking clients around the globe.I love to Design Automation Testing Frameworks with Selenium,Appium,Protractor,Cucumber,Rest-Assured, Katalon Studio and currently exploring lot in Dev-OPS as well. I am currently staying in Mumbai, Maharashtra. Please Connect with me through Contact Us page of this website.

Previous Post
Next Post
August 31, 2019 at 5:48 PM

Hi Ankur,
Thanks for the blog, it is very useful to me.
I want to know can we achieve this using Workbook factory so we dont need to use XSSFSheet etc.

Thanks in advance.

Reply
avatar