dim ds as dataset= ctype(datagrid.datasource,dataset)
dim str as new StringBuilder()
dim fo as new io.streamwriter("path\file.xls")
for icounter as integer=0 to ds.tables(0).rows.count-1
for jcounter as interger=0 to ds.tables[0].columns.count-1
str.Append(ds.Tables(0).Rows(icounter).item(jcounter))
if jocounter<>ds.tables[0].columns.count-1 then
str.append(",")
end if
next
fo.writeline(str.tostring())
next
fo.close