以下给出的Selenium Code for Excel不起作用

时间:2017-02-04 16:36:10

标签: java selenium

package poi;

import java.io.*;

import java.io.File;

import java.io.FileInputStream;

import java.io.IOException;

import java.util.Iterator;

import org.apache.poi.ss.usermodel.Cell;

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.xssf.usermodel.XSSFWorkbook;

class Demo

{

  public static void main(String a[]) throws IOException

  {

    String temp ="C:/santosh_chikne/Selenium Script/test.xlsx"; 

    FileInputStream fs = new FileInputStream(temp);

    Workbook wb = Workbook.getWorkbook(fs);

  }

}

1 个答案:

答案 0 :(得分:0)

尝试如下:

 String temp ="C:/santosh_chikne/Selenium Script/test.xlsx"; 

FileInputStream fs = new FileInputStream(temp);

HSSFWorkbook wb = new HSSFWorkbook(fs);
HSSFSheet sh = wb.getSheet("Sheet1");
Row row = sh.getRow(1);
Cell cell = row.getCell(1);

String valueFromXl = cell.getStringCellValue();