Excel Selenium : Read ,Write and Edit Excel Sheet (Spreadsheet)-- Final
Download the latest binary zip file below link and jars into your project
http://poi.apache.org/download.html
Code below(unlike jxl this should work for both xls and xlsx files) :
Workbook wb = WorkbookFactory.create(new FileInputStream("C:\\Users\\DPK\\Desktop\\test.xls"));
Sheet sheet = wb.getSheet("Sheet1");
System.out.println(sheet.getRow(0).getCell(0).getRichStringCellValue()); // Read Cell
sheet.createRow(1).createCell(1).setCellValue(1212); //---Write into a new cell
sheet.getRow(0).getCell(0).setCellValue("333"); //----Edit existing Cell
FileOutputStream fileOut = new FileOutputStream("C:\\Users\\DPK\\Desktop\\test.xls");
wb.write(fileOut);
fileOut.close();
System.out.print("ok");
No comments:
Post a Comment