User:Narasimha678/sandbox

package test;

import java.io.FileInputStream; import java.text.SimpleDateFormat;

import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.DateUtil; import org.apache.poi.ss.usermodel.Row; import org.apache.poi.xssf.usermodel.XSSFSheet; import org.apache.poi.xssf.usermodel.XSSFWorkbook;

public class ExcelHandler {

public static void main(String[] args) throws Throwable { String ceval = ""; FileInputStream fis = new FileInputStream(System.getProperty("user.dir") + "//src//excelFiles//Data.xlsx"); XSSFWorkbook xls = new XSSFWorkbook(fis); XSSFSheet sheet = xls.getSheet("Suite"); XSSFSheet sheet1 = xls.getSheet("TestCase"); for (Row row : sheet){ ceval = ""; if (row.getCell(2).toString.equals("Y")){ for (Row row1 : sheet1){ if (row1.getCell(0).toString.equals(row.getCell(0).toString)){ for (Cell cell : row1){ ceval = ceval+"-"+tycelldata(cell); }						System.out.println(ceval); }				}			}		}	}

public static String tycelldata(Cell cell){ switch (cell.getCellType){ case Cell.CELL_TYPE_NUMERIC : if (DateUtil.isCellDateFormatted(cell) == true){ SimpleDateFormat abc = new SimpleDateFormat("dd/MM/yyyy"); return String.valueOf(abc.format(cell.getNumericCellValue)); }else return String.valueOf(Integer.valueOf((int)cell.getNumericCellValue)); case Cell.CELL_TYPE_BOOLEAN : return String.valueOf(cell.getBooleanCellValue); case Cell.CELL_TYPE_FORMULA : return cell.getCellFormula; case Cell.CELL_TYPE_STRING : return cell.getStringCellValue; default : return ""; }				} } http://www.codetreat.com/extract-data-from-excel-sheet-with-apache-poi-java-example/ http://www.javabeat.net/articles/print.php?article_id=41 http://viralpatel.net/blogs/java-read-write-excel-file-apache-poi/comment-page-1/ http://prp-datainput.googlecode.com/svn-history/r24/trunk/EduWeb/EduWeb/Strategies/StrategyImpl/ImportStrategyDegree.cs