'文件名:ReportCheckoutPrint.aspx.vb
Imports System.Data.SqlClient
Imports System.Data
Partial Class ReportManage_ReportCheckOutPrint
Inherits System.Web.UI.Page
Private MyReportCheckoutForm As ReportManage_ReportCheckoutForm
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
'将查询结果输出到Excel文件中
MyReportCheckoutForm = Context.Handler
Dim MySQL As String = MyReportCheckoutForm.MyPrintSQL
Me.Label1.Text = Session("MyCompanyName").ToString() + "旅客结账信息表"
Me.Label2.Text = MyReportCheckoutForm.MyPrintDate
Dim MyConnectionString As String = ConfigurationManager.ConnectionStrings("MyHotelDBConnectionString").ConnectionString
Dim MyAdapter As New SqlDataAdapter(MySQL, MyConnectionString)
Dim MySet As New DataSet()
MyAdapter.Fill(MySet)
Me.DataGrid1.DataSource = MySet
Me.DataGrid1.DataBind()
Me.Response.ContentType = "application/vnd.ms-excel"
Me.Response.Charset = ""
'关闭 ViewState
Me.EnableViewState = False
Dim MyWriter As System.IO.StringWriter
Dim MyWeb As System.Web.UI.HtmlTextWriter
'将信息写入字符串
MyWriter = New System.IO.StringWriter()
'在Web窗体页上写出一系列连续的HTML特定字符和文本
MyWeb = New System.Web.UI.HtmlTextWriter(MyWriter)
'将DataGrid中的内容输出到HtmlTextWriter对象中
Me.DataGrid1.RenderControl(MyWeb)
'把HTML写回浏览器
Response.Write(MyWriter.ToString())
End Sub
End Class