使用Java和JXL / JExcel读取电子表格

时间:2016-03-10 19:05:58

标签: java selenium selenium-webdriver jxl

我的代码正在打开电子表格,只是阅读最后一行......我做错了什么?

Workbook workbook = Workbook.getWorkbook(new File("C:/promocoes.xls"));

//Number of lines of plannilha
Sheet sheet = workbook.getSheet(0);  
int linhas = sheet.getRows();

for(int i = 0; i < linhas; i++){

    Cell a1 = sheet.getCell(0, i);
    Cell a2 = sheet.getCell(1, i);           

    String as1 = a1.getContents();
    String as2 = a2.getContents();

        nomepromocao = as1;
        tipopromocao = as2;         
}
workbook.close();

    driver.findElement(By.name("nomePromocao")).sendKeys(nomepromocao);
    driver.findElement(By.name("descPromocao")).sendKeys(tipopromocao);

enter image description here

1 个答案:

答案 0 :(得分:1)

您需要在循环中的下一次迭代之前使用这些值:

PairDStreamFunctions.updateStateByKey

您还可以存储值以便以后使用它们:

updateStateByKey[S](updateFunc: (Seq[V], Option[S]) ⇒ Option[S], partitioner: Partitioner, initialRDD: RDD[(K, S)])(implicit arg0: ClassTag[S]): DStream[(K, S)]