package first;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.usermodel.WorkbookFactory;
public class example {
public static String val;
public static String getval(String stname,int rownum,int cellnum) throws Exception, FileNotFoundException, IOException
{
Workbook wb=WorkbookFactory.create(new FileInputStream("C:Book1.xls"));
int st=wb.getSheetIndex(stname);
Sheet s=wb.getSheetAt(st);
Row r=s.getRow(rownum);
Cell c=r.getCell(cellnum);
val=c.getStringCellValue();
return val;
}
public static void main(String[] args) throws FileNotFoundException, IOException, Exception {
String s=getval("sheet1",3,1);
System.out.println(s);
}
}