我在Mac中使用硒,并试图从xlsx获取数据,但无法获取它。你能推荐我一些视频吗?我尝试了很多却没有发现。
import java.io.File;
import java.io.FileInputStream;`enter code here`
import java.io.FileNotFoundException;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
public class New {
public static void main(String[] args) {
File src = new File("/Users/jaiyanth/Documents/workspace/testcase/test.xlsx");
FileInputStream fis = new FileInputStream(src);
XSSFWorkbook wb = new XSSFWorkbook(fis);
XSSFSheet sheet1 = wb.getSheetAt(0);
String data1 = sheet1.getRow(0).getCell(0).getStringCellValue();
System.out.println("data from excel is " + data1);
String data2=sheet1.getRow(0).getCell(1).getStringCellValue();
System.out.println("data from excel is " + data2);
}
}