-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathReadExcel.java
More file actions
37 lines (23 loc) · 1008 Bytes
/
ReadExcel.java
File metadata and controls
37 lines (23 loc) · 1008 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
//Read Excel values into the console
package Framework;
import java.io.File;
import java.io.FileInputStream;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
public class ReadExcel {
public static void main(String[] args) throws Throwable {
// TODO Auto-generated method stub
//get the location of excel file
File src = new File("D:\\Quastech\\testdata.xlsx");
//Read the excel file
FileInputStream fileip = new FileInputStream(src);
//XLSX file
Workbook wb = new XSSFWorkbook(fileip);
XSSFSheet sheet1 = (XSSFSheet)wb.getSheetAt(0);
System.out.println(sheet1.getRow(1).getCell(0).getStringCellValue());
System.out.println(sheet1.getRow(1).getCell(1).getStringCellValue());
System.out.println(sheet1.getRow(2).getCell(0).getStringCellValue());
System.out.println(sheet1.getRow(2).getCell(1).getStringCellValue());
}
}