 import org.apache.poi.ss.usermodel.*;
import org.apache.poi.hssf.usermodel.*;
import org.apache.poi.xssf.usermodel.*;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.util.CellReference;
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
import java.io.*;
import java.util.*;
import javax.swing.*;
// reading from excel
public class apachePOI6
{
public static void main(String arg[])
{ 
try {
    FileInputStream file = new FileInputStream(new File("new.xls"));
 
    Workbook workbook = new HSSFWorkbook(file);
    Sheet sheet = workbook.getSheetAt(0);
    Cell cell = null;
 
    //Update the value of cell
    double a[]=new double[3];
    double r[]=new double[3];
    for(int i=0;i<3;i++)
      {
	  cell = sheet.getRow(i+1).getCell(3);
      r[i]=cell.getNumericCellValue();
      cell = sheet.getRow(i+1).getCell(2);
      a[i]=cell.getNumericCellValue();
      a[i]*=(1+r[i]);
      cell.setCellValue(a[i]);
      }     
    file.close();
     
    FileOutputStream outFile =new FileOutputStream(new File("new.xls"));
    workbook.write(outFile);
    outFile.close();
     
} catch (FileNotFoundException e) {
    e.printStackTrace();
} catch (IOException e) {
    e.printStackTrace();
}
}
}
