the code which i hav already throws some error wen i debug
here is my code
plz reply me as soon as possible
Private Sub Page_Load(ByVal sender As _
System.Object, ByVal e As System.EventArg s) _
Handles MyBase.Load
Dim dt As DataTable = _
CType(Applicati on.Item("MyData Table"), DataTable)
Response.Conten tType = "applicatio n/ms-excel"
Response.AddHea der("Content-Disposition", _
"inline;filenam e=test.xls")
Response.Write( ConvertDtToTDF( dt))
End Sub
'Converts a DataTable to Tab Delimited Format
Private Function ConvertDtToTDF( ByVal _
dt As DataTable) As String
Dim dr As DataRow, ary() As Object, i As Integer
Dim iCol As Integer
'Output Column Headers
For iCol = 0 To dt.Columns.Coun t - 1
Response.Write( dt.Columns(iCol ).ToString & vbTab)
Next
Response.Write( vbCrLf)
'Output Data
For Each dr In dt.Rows
ary = dr.ItemArray
For i = 0 To UBound(ary)
Response.Write( ary(i).ToString & vbTab)
Next
Response.Write( vbCrLf)
Next
End Function
here is my code
plz reply me as soon as possible
Private Sub Page_Load(ByVal sender As _
System.Object, ByVal e As System.EventArg s) _
Handles MyBase.Load
Dim dt As DataTable = _
CType(Applicati on.Item("MyData Table"), DataTable)
Response.Conten tType = "applicatio n/ms-excel"
Response.AddHea der("Content-Disposition", _
"inline;filenam e=test.xls")
Response.Write( ConvertDtToTDF( dt))
End Sub
'Converts a DataTable to Tab Delimited Format
Private Function ConvertDtToTDF( ByVal _
dt As DataTable) As String
Dim dr As DataRow, ary() As Object, i As Integer
Dim iCol As Integer
'Output Column Headers
For iCol = 0 To dt.Columns.Coun t - 1
Response.Write( dt.Columns(iCol ).ToString & vbTab)
Next
Response.Write( vbCrLf)
'Output Data
For Each dr In dt.Rows
ary = dr.ItemArray
For i = 0 To UBound(ary)
Response.Write( ary(i).ToString & vbTab)
Next
Response.Write( vbCrLf)
Next
End Function
Comment