无法使用Robotium从Excel工作表中读取数据

时间:2014-01-07 11:56:53

标签: java android excel robotium

我无法从Excel工作表中读取数据。请帮帮我 我正在使用以下代码。在excelsheet中我有2个coloumns-用户名和密码,两者都有值。我已将test.xls文件放在Tablet的内部存储器中。

//阅读excel文件

public static String Readexcel(int row,int col) throws IOException  { 

    File storage = Environment.getExternalStorageDirectory();

    String filename = "test.xls";
    File myfile = new File(storage, filename);
    String s = "";

    try
    {
        FileInputStream fis = new FileInputStream(filename);
        HSSFWorkbook myWorkBook = new HSSFWorkbook(fis);
        HSSFSheet mySheet = myWorkBook.getSheetAt(0);
        HSSFRow row1 = mySheet.getRow(row);
        HSSFCell cell1 = row1.getCell(col);
        s = cell1.getRichStringCellValue().getString();
        System.out.println("Cell 1 : "+s);
        Log.d("cell value",s );

        System.out.println(s);
            return s;

    }
    catch (IOException e) {
        e.printStackTrace();
        return null;
    } 

    }

public void test1invaliedcredentials() throws Exception{    

    String username;
        String password;
    solo.sleep(2000);
    solo.clearEditText(0);

    solo.clearEditText(1);
    solo.clearEditText(2);
    username = Readexcel(0,0);
        password = Readexcel(0,1);
        solo.enterText(0,username);
        solo.enterText(1, password);
    solo.clickOnButton(0);
}

0 个答案:

没有答案