You are on page 1of 2

Framework concept: poi api

Framework concepts

properties

Poi api

purpose:

Handle the excel files

Reading data
Inserting data
create excel
Delete excel
create sheets
Rows
columns
cell values

Excel file types

.xls and .xlsx

older newer
97-2003

poi has api commands that handle


both excel types

Api's

java webdriver poi api


oracle thoughtworks apachi

google java8 api


google webdriver api
google poi api
javadocs
search ctrl+f
workbook(it is interface)
click on hssfworkbook child class
their are mmany methods
hssfclass interface xssfclass

Hssfworkbook workbook xssfworkbook

hssfsheet sheet xssfsheet

hssfrow row xssfrow

hssfcell cell xssfcell


4 interfaces:
workbook
when save excel file as workbook
complete excel file is workbook
sheet
in wokbook down as sheets you can give name to sheets
Row
sheet has rows
cell
Row has cells

workbook has child classes


hssfworkbook ,xssfworkbook
ctrl+f sheet
sheet has child classes
hssfsheet,xssfsheet
Row has child classes
hssfrow ,xssfrow
cell has child classes
hssfcell,xssfcell

hssfclasses for .xls files


xssfclasses for .xlsx files

practical-
new>javaproject>poiproj>
poiproj>new>folder>libraries
paste poi jars from doc pi,poiooxml,
poiooxml schemas same versionpaste it in
to libraries configure it

class>demo>
main>
download excel files to project
EmployeeData sheet name
main()>
file excelfile=new file("src//excelfile"):
fileinputstream fis=new fileinputstream(excelfile);
Hsfworkbook workbook=new hssfworkbook(fis);
hssfworkbook has getsheet at method takes index
hssfsheet sheet=workbook.getsheetAt(0);//return type hssfsheet
hssfsheet has getrow method
...
hssfrow row=sheet.getrow(3//index);//return type hssfrow
row has cells
hssfcell cell=row.getcell(2//cell number);//return tpe hssfcell
int cellvalue=cell.getStringcellvalue();//return type int
s.o.p(cellvalue);

run>o/p

You might also like