Sunday, October 5, 2008

Export Datatable into Text File

Pre Requisite - abc.xls with one sheet with some values in first column

textfile="c:\demo.txt"
Set fso=createobject("scripting.filesystemobject")
Set f=fso.createtextfile(textfile,2)

datatable.Import("C:\abc.xls")
set dg=datatable.GetSheet(1)

x=dg.getparametercount
rc=dg.getrowcount

For i=1 to x
n=dg.getparameter(i).name ' Gives the First coulmn name
Set pmg=dg.getparameter(n)
f.writeline(n)
For j=1 to rc
f.writeline(pmg.valuebyrow(j))
next
Next

No comments:

Post a Comment