How To open excel file append mode using selenium webdriver using jxl

762 views
Skip to first unread message

Karthikeyan Ar

unread,
Jul 22, 2013, 12:01:38 AM7/22/13
to seleniu...@googlegroups.com
Any body now how to open the excel file using opening append mode............

this my code every time it open the new excel.......

package Jobwork;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;
import java.util.concurrent.TimeUnit;

import jxl.Workbook;
import jxl.write.Label;
import jxl.write.WritableSheet;
import jxl.write.WritableWorkbook;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.Select;

public class Sulekha {
        WritableWorkbook wb;
static int rv = 0;
public static void fun(WebDriver driver,String city,String sval)
{
driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
        Select Sel =new Select(driver.findElement(By.id("CityDrpDwn")));
        Sel.selectByVisibleText(city);
        WebElement search = driver.findElement(By.id("SearchInput"));
        search.sendKeys(sval);
        WebElement ele = driver.findElement(By.id("ui-id-1"));
        List <WebElement> listv = ele.findElements(By.tagName("li"));
        PrintWriter pr=null;
        String path = "D:\\s.txt";
        wb = Workbook.createWorkbook(new File("D:\\s1.xls"));
WritableSheet sh = wb.createSheet("Suresh", 1);
        int cv = 0;
        for(WebElement wval : listv)
        {           
Label l1 = new Label(cv,rv,i);
sh.addCell(l1);
cv++;
}
cv =0;
rv++;
        }
wb.write();
wb.close();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}        
        //diver.manage().timeouts().implicitlyWait(40, TimeUnit.SECONDS);
        search.clear();
        System.out.println("completed");
}
public static void geturl(WebDriver driver,String url)
{
driver.get(url);
}
public static void main(String[] args) {
// TODO Auto-generated method stub
WebDriver driver = new FirefoxDriver();
geturl(driver,url);
fun(driver,"Chennai","Individual House");
fun(driver,"Bangalore","Rent House");
fun(driver,"Hyderabad","2BHK");
fun(driver,"Bangalore","1BHK");
fun(driver,"Kolkata","Approved Plots");
}

}

Krishnan Mahadevan

unread,
Jul 22, 2013, 1:45:02 AM7/22/13
to Selenium Users
Why doesnt googling help you here ?
What makes you think that this is related to Selenium when you clearly know you are playing around with Excel sheets ?

Lastly, 
what makes you think that the Selenium-Users forum is a "One stop shop for all your queries" ?

Please help keep the forums relevant by posting queries that are related to Selenium/WebDriver ONLY.



Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/



--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/4a683c15-1631-40f2-ad07-08f7a97484aa%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Reply all
Reply to author
Forward
0 new messages