Friday, 6 May 2016

All About Excel in Selenium: POI & JXL


File IO is a critical part for any software process. We frequently create a file, open it & update something or delete it in our Computers. Same is the case with Selenium Automation. We need a process to manipulate files with Selenium.
Java provides us different classes for File Manipulation with Selenium. In this tutorial we are going to learn how can we read and write on excel file with the help of Java IO package and Apache POI library.

Exporting Excel

  • How to handle excel file using POI (Maven POM Dependency)
    To read or write an Excel, Apache provide a very famous library POI. This library is capable enough to read and write both XLS and XLSX file format of excel.
    To read XLS files an HSSF implementation is provided by POI library.
    To read XLSX , XSSF implementation of POI library will be the choice. Let's study these implementations in detail.
If you are using maven in your project the maven dependency will be
<dependency>
<groupId>org.apache.poi</groupId>
    <artifactId>poi</artifactId>
    <version>3.9</version>
</dependency>
Or you can simply download the latest version POI jars from http://poi.apache.org/download.html & download poi-bin-3.10-FINAL-20140208.zip
When you download the zip file for this jar , you need to unzip it and add these all jars to the class path of your project.


Classes and Interfaces in POI:

Following is a list of different Java Interfaces and classes in POI for reading XLS and XLSX file-
  • Workbook: XSSFWorkbook and HSSFWorkbook classes implement this interface.
  • XSSFWorkbook: Is a class representation of XLSX file.
  • HSSFWorkbook: Is a class representation of XLS file.
  • Sheet: XSSFSheet and HSSFSheet classes implement this interface.
  • XSSFSheet: Is a class representing a sheet in a XLSX file.
  • HSSFSheet: Is a class representing a sheet in a XLS file.
  • Row: XSSFRow and HSSFRow classes implement this interface.
  • XSSFRow: Is a class representing a row in sheet of XLSX file.
  • HSSFRow: Is a class representing a row in sheet of XLS file.
  • Cell: XSSFCell and HSSFCell classes implement this interface.
  • XSSFCell: Is a class representing a cell in a row of XLSX file.
  • HSSFCell: Is a class representing a cell in a row of XLS file.

4 comments:

  1. My friend Suggest me this blog and I can say this is the best blog to get the basic knowledge.Thank you so much for this Selenium Training in Chennai blog

    ReplyDelete
  2. Thanks for the great information ,was looking for this information from long.Great blog SAP Basis Training in Chennai

    ReplyDelete
  3. Best blog.Got to learn new things.Thanks for this Blog SAP HR Training in Chennai blog

    ReplyDelete
  4. Great place to learn about the new things and got great knowledgeSAP MM Training in Chennai

    ReplyDelete