POI Programming Questions & Answers

Explore model answers categorized by subjects like Java, HTML, DBMS, and more.

POI Programming Questions & Answers

How to find the name of the excel sheet?

Answer:

we know that for using to Event of POI we are constructing an instance of org.apache.poi.hssf.eventmodel.HSSFRequest. and for registering a class we have to create listenerorg.apache.poi.hssf.eventmodel.HSSFListener interface and useHSSFRequest.addListener(yourlistener, recordsid) method. The record sid should be a static reference number (such as BOFRecord.sid) contained in the classes in org.apache.poi.hssf.record.Alternatively we can call HSSFRequest.addListenerForAllRecords(mylistener).

If we can register in listeners in the HSSFRequest object successfully we can construct an instance oforg.apache.poi.poifs.filesystem.FileSystem and pass it our XLS file as inputstream. We can either pass this, along with the request we constructed, to an instance of HSSFEventFactory via theHSSFEventFactory.processWorkbookEvents(request, Filesystem) method, Once we make this call, the listeners that we constructed receive calls to their processRecord(Record) methods with each Record they are registered to listen for until the file has been completely read.


How to Find String Values of Cell Using POI?

Answer:
we are going to find the String Values of Cell of  an excel sheet using POI2.5.0 API Event. The class org.apache.poi.hssf.record.LabelSSTRecord extends Record implements CellValueRecordinterface and java.lang.Comparable. this is used  to make reference of a string  and a column value. 

Described the method getSSTIndex?

Answer:
This method is used to give the index in the SSTRecord. and The return type of this getSSTIndex() method is integer (index of string in the SST Table).

Described the method getString(int i)?

Answer:

This method is used to get the string  value from SSTRecord .


described the method getType()?

Answer:

This method is used to find type of object that is marked. This method returns short type of object.


How to set picture as background of slide?

Answer:
we are going to take a slide. In this slide we are set the background in the slide by inserting the picture. To set the picture as background in slide we are using setPictureData(nameofpicture ) method. We are setting the  pattern type of the picture. To set the pattern we are usingsetFillType(filltype) method. 

How to change the background of the master slide?

Answer:

firstly we are going to creating a master slide for the slide show. To create slide show we are using SlideShow constructor and to create master slide we are using SlideMaster constructor. After the creation of the masterslide we are going to create the fill. this is used for setting background and for adding a picture. then We are using getFill() method to create the fill object. The setFillType(type) is used allow to set the type of fill. In this program, we are using picture type. Finally we are adding the picture into master slide in fill.