Skip to main content

Posts

Showing posts from February, 2021

Excel Write(simple and conditional) - Apache POI- Selenium - MacOS

  As we already gave an idea  on our last tutorial of minimum requirement to run excel read /write Jar file of Apache POI A simple way to enter data in excel file is  where our data file is blank and present in the path " /Users/priyankac/Desktop/Datatest.xlsx " reference to get a path location in Mac check the blog Blank excel present with header         @Test public void test2() throws IOException{ // create object of fileoutput stream FileInputStream fis = new FileInputStream("/Users/priyankac/Desktop/Datatest.xlsx"); XSSFWorkbook workbook = new XSSFWorkbook(fis); XSSFSheet sheet = workbook.getSheetAt(0); //As 0th row is occupied with header we will start entering data from 1st row, 0th column to 2nd column one by one sheet.getRow(1).createCell(0).setCellValue("Priyanka Chauhan"); sheet.getRow(1).createCell(1).setCellValue("500"); sheet.getRow(1).createCell(2).setCellValue("Java"); //entering data from 1st row, 0th c...

3 way's to Read from excel......Apache POI- Selenium-MacOS

To work with excel  first we need to have below jars present on the system from Apache POI. Download files from Binary distribution .tar.gz for Mac and zip from windows, link once all jar files are downloaded Go to Java project-> right click-> Build Path-> configure Build path Add external Jars  and click apply and OK If you are using Maven add the Apache POI dependency in POM.XML Go to Maven repository and search for Apache POI, f irst 2 dependency will be good to go with Add the dependency in your POM.XML file <dependency>     <groupId>org.apache.poi</groupId>     <artifactId>poi</artifactId>     <version>5.0.0</version> </dependency> <dependency>     <groupId>org.apache.poi</groupId>     <artifactId>poi-ooxml</artifactId>     <version>5.0.0</version> </dependency> And your are good to go with Excel read and writ...