Below Code demonstrates how to save scorecard data in MS Excel file
Webtable that I am using can be seen here http://imsports.rediff.com/score/in_asa_101463.html
Our objective here is to store Batting Scorecard of Kolkata Knight riders into Excel File.
'//Creating object for getting webtable objects
Set odesc=description.Create
odesc("html tag").value="table"
'// Get total webtable count present on webpage
set otablecollector =browser("title:=.*").Page("title:=.*").ChildObjects(odesc)
print otablecollector.count
'//Returns 6 indicating there are 6 webtales on given page
//We are interested in webtable with index 4. As it stores Batting score Card for Kolkata
'//Lets get how many rows are present there in this table
rc=otablecollector(4).rowcount
print rc '//Gives o/p as 12 (11 players + header row )
'//Lets get how many columns are present in row 1 for same table table
cc=otablecollector(4).columncount(1)
print cc
'//Gives o/p as 8. Hence 8 columns are there in row 1
'// Table has 12 rows and 8 columns
''Lets print all data of row 1
'''It gives header column information
'
'For c=1 to cc
'
'print otablecollector(4).getcelldata(1,c)
'
'Next
'
''o/p
'
''Kolkata
''119-9 (20)
''Runs
''Balls
''4s
''6s
''SR
'For dc=1 to cc
'
'dcolumn= otablecollector(4).getcelldata(1,dc)
'
'var1=datatable.GetSheet(1).AddParameter(dcolumn, "")
'
'Next
Set oexl=createobject("excel.application")
oexl.Visible=true
set oworkbook=oexl.Workbooks.Add()
set oworksheet=oworkbook.worksheets.add()
'
For r=1 to rc
For c=1 to cc
dcolumn= otablecollector(4).getcelldata(r,c)
oworksheet.cells(r,c)=dcolumn
Next
Next
oworkbook.saveas "c:\ss.xls"
Set oexl=nothing
Output file snap:
Webtable that I am using can be seen here http://imsports.rediff.com/score/in_asa_101463.html
Our objective here is to store Batting Scorecard of Kolkata Knight riders into Excel File.
'//Creating object for getting webtable objects
Set odesc=description.Create
odesc("html tag").value="table"
'// Get total webtable count present on webpage
set otablecollector =browser("title:=.*").Page("title:=.*").ChildObjects(odesc)
print otablecollector.count
'//Returns 6 indicating there are 6 webtales on given page
//We are interested in webtable with index 4. As it stores Batting score Card for Kolkata
'//Lets get how many rows are present there in this table
rc=otablecollector(4).rowcount
print rc '//Gives o/p as 12 (11 players + header row )
'//Lets get how many columns are present in row 1 for same table table
cc=otablecollector(4).columncount(1)
print cc
'//Gives o/p as 8. Hence 8 columns are there in row 1
'// Table has 12 rows and 8 columns
''Lets print all data of row 1
'''It gives header column information
'
'For c=1 to cc
'
'print otablecollector(4).getcelldata(1,c)
'
'Next
'
''o/p
'
''Kolkata
''119-9 (20)
''Runs
''Balls
''4s
''6s
''SR
'For dc=1 to cc
'
'dcolumn= otablecollector(4).getcelldata(1,dc)
'
'var1=datatable.GetSheet(1).AddParameter(dcolumn, "")
'
'Next
Set oexl=createobject("excel.application")
oexl.Visible=true
set oworkbook=oexl.Workbooks.Add()
set oworksheet=oworkbook.worksheets.add()
'
For r=1 to rc
For c=1 to cc
dcolumn= otablecollector(4).getcelldata(r,c)
oworksheet.cells(r,c)=dcolumn
Next
Next
oworkbook.saveas "c:\ss.xls"
Set oexl=nothing
Output file snap:
No comments:
Post a Comment