I won't be downloading any jars and
importing any charges into the project
but I'll directly be adding my
dependencies in my pond on XML file so
to begin with the two main API is being
used in any readwrite walk in java java
dot io api and apache apo i java dot io
api comes with java it's mainly it's
it's an api that is used to read and
write data apache py is another API that
allows programmers to play with MS
Office using Java Java an i/o API is in
build but we still need to have the
Apache Pio I dependencies so I'll do
that from the Apache or actually from
the maven repository website I'll add
this URL in the description below but
I've already added that over in my phone
on XML file so long with Apache Pio I
and Apache XML dependencies have also
added the text entry in the selenium
dependencies you over so let's get to it
so now let's create a new method let's
call it theta read test
but the first thing to do is to point
through the excel sheet location so we
do then using the file class let's
create an object of the class file and
we pass our exact location your that's
not the complete path xlsx file
toughing it's gonna throw an error let's
hover over this so we need to import the
file class from the java dot io package
the second step is to pass the source as
a parameter in the file input stream
class file input stream class is another
class than belongs to the Java on an i/o
package and also helps in loading the
exergy file input stream
so let's import this class still
throwing an arrow you're asking us to
add throw its declaration let's go for
the generic exception
so then handles all the various
different kinds of exceptions so
basically we are looking at exception
handling and now let's close the
complain excel workbook in order to do
that we would use a class called XSS F
for book
belonging to the Apache package so let's
create an object of that class and let's
pass FIS in your so now we I'm going to
import the exercise of wood glass
belonging to the Apache API package XSS
F walk book deals with Excel SX file but
say if we had or dot XLS file not to
work on on XLS files if you basically
use the same code but instead of XS s f4
poke class we use the HSS SF class so
I'm going to add that code your button
I'm going to comment it now this is for
dot XLS files
so now what the XS sf4 book does is it
basically loads your entire workbook but
now what I'm looking for is a specific
sheet in my voke book so now in my voke
book named read data I have two
different sheets data data - I'm
interested in the data within the sheet
one so in order to pass the information
you know I'm going to make use of the
glass x ssf sheet let's call it Sheen
so now let's point at the entire boat
book makes SF and then get a specific
sheet from that workbook so get sheet
pad the 0th index so that's the for
shear let's import this class from the
Apache package using this sheet you can
perform all sorts of eight operations
such as reading data from a specific row
and a specific column so let's test that
out so let's get data from the second
row and second column so okay cell pick
second column and let's get the string
value of the data now you can store this
data in a string so let's clear a new
string and let's name it say enter you
won
let's print out this entry to check if
we're getting the value required so that
is this control space that data in the
box is then we're gonna print out that
data entry point there we go always make
sure to close the workbook once your
operations done so let's close the
workbook by simply using x SF s dot
close there we go now let's run this as
a test ng test and see the results oh
it's not showing me the honest test
energy because I forgot to add the test
annotation or you can follow my video on
how to set up tests and G in Eclipse to
understand more about this I'm going to
add a link to that as well below
I'll file let's run as destiny test so
here we have one runs one passes zero
failures and the data in the box was
pass one let's go ahead and verify that
so we are looking at the second row and
the second column pass one there it is