Java dataprovider excel文件读取如何跳过第一行 标题
如何跳过第一行,如果我在for循环中使i=1,为 第一行值Java dataprovider excel文件读取如何跳过第一行 标题,java,selenium-webdriver,Java,Selenium Webdriver,如何跳过第一行,如果我在for循环中使i=1,为 第一行值 如何跳过第一行,如果我在for循环中设置i=1,则为 第一行值 包excel2; 导入java.io.FileInputStream; 导入java.io.FileNotFoundException; 导入java.io.IOException; 导入org.apache.poi.xssf.usermodel.XSSFRow; 导入org.apache.poi.xssf.usermodel.xssfheet; 导入org.apache.
如何跳过第一行,如果我在for循环中设置i=1,则为
第一行值
包excel2;
导入java.io.FileInputStream;
导入java.io.FileNotFoundException;
导入java.io.IOException;
导入org.apache.poi.xssf.usermodel.XSSFRow;
导入org.apache.poi.xssf.usermodel.xssfheet;
导入org.apache.poi.xssf.usermodel.xssf工作簿;
导入org.testng.annotations.DataProvider;
导入org.testng.annotations.Test;
公共类数据提供者2{
XSSF表;
int行;
int col;
@测试(dataProvider=“excel”)
public void tc_01(字符串Srno、字符串名称、字符串添加){
System.out.println(“名称:+Srno+”\t位置:+name+”添加:
“+添加);
}
/**
*@author pritesh
*@返回
*@抛出异常
*/
@数据提供者(name=“excel”)
公共对象[][]abc()引发IOException{
FileInputStream fl=new
FileInputStream(“C:\\Users\\pritesh\\Desktop\\x22.xlsx”);
XSSF工作簿=新XSSF工作簿(fl);
sheet=book.getSheetAt(0);
行=sheet.getLastRowNum()+1;
col=sheet.getRow(0.getLastCellNum();
Object[][]obj=新对象[行][col];
对于(int i=1;i
how to skip first row , if i make i=1 in for loop giving null null for
first row values
how to skip first row , if i make i=1 in for loop giving null null for
first row values
package excel2;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
public class DataProvider2 {
XSSFSheet sheet;
int row ;
int col;
@Test(dataProvider = "excel")
public void tc_01(String Srno, String name,String add) {
System.out.println("name :" + Srno + "\t palce :" + name + " add :
"+add);
}
/**
* @author pritesh
* @return
* @throws IOException
*/
@DataProvider(name = "excel")
public Object[][] abc() throws IOException {
FileInputStream fl = new
FileInputStream("C:\\Users\\pritesh\\Desktop\\x22.xlsx");
XSSFWorkbook book = new XSSFWorkbook(fl);
sheet = book.getSheetAt(0);
row = sheet.getLastRowNum()+1;
col = sheet.getRow(0).getLastCellNum();
Object[][] obj = new Object[row][col];
for (int i = 1; i <row; i++) {
XSSFRow rw = sheet.getRow(i);
for (int j = 0; j <col; j++) {
obj[i][j] = rw.getCell(j).getStringCellValue();
}
}
return obj;
}
}