导出动态获取的tab或数据库中的数 Dim tab As New DataTable
Dim i, m As Integer
Dim filename As String = “teacher”
tab = f.Tea_Sel2
Response.Clear()
Response.Buffer = False
Response.ContentType = "application/octet-stream"
Response.AppendHeader("content-disposition", "attachment;filename=" & filename & ".xls;")
'Response.Write("教师账号表" & vbCr & vbLf)
Dim ss As String = ""
For m = 0 To tab.Columns.Count - 1
ss += tab.Columns(m).Caption.ToString + Chr(9)
Next
ss += vbCr & vbLf
For i = 0 To tab.Rows.Count - 1
For m = 0 To tab.Columns.Count - 1
ss += tab.Rows(i)(m).ToString + Chr(9)
Next
ss += vbCr & vbLf
Next
Response.Write(ss)
Response.Flush()
Response.End()据到电子表格