-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTest4.java
More file actions
42 lines (34 loc) · 1.01 KB
/
Test4.java
File metadata and controls
42 lines (34 loc) · 1.01 KB
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
38
39
40
41
package dataDriven;
import java.io.FileInputStream;
import java.io.IOException;
import org.apache.poi.EncryptedDocumentException;
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;
import org.testng.annotations.Test;
public class Test4 {
@Test
public void tc1() throws EncryptedDocumentException, IOException {
FileInputStream fis=new FileInputStream("./data.xlsx");
Workbook wb = WorkbookFactory.create(fis);
Sheet sh = wb.getSheet("Sheet1");
int rownumb = sh.getLastRowNum();
for(int i=1;i<rownumb;i++) {
Row row = sh.getRow(i);
String rowData = row.getCell(0).getStringCellValue();
if(rowData.equals("2"))
{
short cellnum = row.getLastCellNum();
for(int j=0;j<cellnum;j++) {
String data = row.getCell(j).getStringCellValue();
System.out.println(data);
}
break;
}
else
{
System.out.println("data not found");
}
}
}}