Writing results to XLS ( MS EXCEL ) using Apache POI.
This post was updated on .
This code has been verified:
public void writePOI(String flag ,String pagename, String fieldname, String fvalue, int excelrow, String fname, String desc)
throws Exception
{
try{
boolean res= isFileExist(); // a small function should be written with this name --- isFileExist --- to verify the file existance
if (res==false)
{
// a small function should be written with this name --- createNewFile --- to create a new file if file not there:
createNewFile ( "c:\\resultsall.xls");
}
HSSFWorkbook sampleWorkbook = null;
HSSFSheet sampleDataSheet = null;
FileInputStream fi = new FileInputStream (fname);
sampleWorkbook = new HSSFWorkbook(fi);
Re: Writing results to XLS ( MS EXCEL ) using Apache POI.
Administrator
Thanks for posting it. One small suggestion though, it would help if you could post code comments along with with.
It would help newbie in understanding as to what is going on.
oolean res= isFileExist(); // a small function should be written with this name --- isFileExist --- to verify the file existance
if (res==false)
{
// a small function should be written with this name --- createNewFile --- to create a new file if file not there:
createNewFile ( "c:\\resultsall.xls");