import com.thoughtworks.selenium.DefaultSelenium;
import java.io.FileOutputStream;
import jxl.Workbook;
import jxl.write.WritableWorkbook;
import jxl.write.WritableSheet;
import jxl.write.Label;
public class ExcelWrite
{
public static void main(String[] args) throws Exception
{
String x;
DefaultSelenium s=new DefaultSelenium("localhost",1111,"*firefox","http://");
s.start();
s.open("http://content.icicidirect.com/newsiteContent/Market/MarketStats.asp?stats=DailySharePrices");
s.windowMaximize();
Thread.sleep(8000);
int r=s.getXpathCount("id('gridSource')/x:tbody/x:tr").intValue();
FileOutputStream fs=new FileOutputStream("e:\\sampledata.xls");
WritableWorkbook wb=Workbook.createWorkbook(fs);
WritableSheet ws=wb.createSheet("sheet1",0);
for(int i=1;i<=r;i++)
{
x=s.getText("xpath=id('gridSource')/x:tbody/x:tr["+i+"]/x:td[1]");
ws.addCell(new Label(0,i,x));
}
wb.write();
wb.close();
}
}
import java.io.FileOutputStream;
import jxl.Workbook;
import jxl.write.WritableWorkbook;
import jxl.write.WritableSheet;
import jxl.write.Label;
public class ExcelWrite
{
public static void main(String[] args) throws Exception
{
String x;
DefaultSelenium s=new DefaultSelenium("localhost",1111,"*firefox","http://");
s.start();
s.open("http://content.icicidirect.com/newsiteContent/Market/MarketStats.asp?stats=DailySharePrices");
s.windowMaximize();
Thread.sleep(8000);
int r=s.getXpathCount("id('gridSource')/x:tbody/x:tr").intValue();
FileOutputStream fs=new FileOutputStream("e:\\sampledata.xls");
WritableWorkbook wb=Workbook.createWorkbook(fs);
WritableSheet ws=wb.createSheet("sheet1",0);
for(int i=1;i<=r;i++)
{
x=s.getText("xpath=id('gridSource')/x:tbody/x:tr["+i+"]/x:td[1]");
ws.addCell(new Label(0,i,x));
}
wb.write();
wb.close();
}
}
No comments:
Post a Comment