2011-07-07 3 views
0

グリッドビューをExcelにエクスポートできますが、ファイル名とパスを尋ねるウィンドウを表示しないようにするにはどうすれば無効にできますか? また、ファイルを保存するパスを設定する方法はありますか? > //コード内の後ろプロンプトウィンドウなしでExcelにグリッドビューをエクスポート

Private Sub ExportGridView() 

    Dim filename As String 
    filename = ddlMonth.SelectedValue & "-" & ddlYear.SelectedValue 

    Dim attachment As String = "attachment; filename=" & filename & ".xls" 

    Response.ClearContent() 
    Response.Buffer = True 
    Response.Charset = "UTF-8"   
    Response.AddHeader("content-disposition", attachment) 
    Response.ContentEncoding = System.Text.Encoding.GetEncoding("UTF-8") 
    Me.EnableViewState = False 
    Response.ContentType = "application/ms-excel" 

    Dim sw As New StringWriter() 
    Dim htw As New HtmlTextWriter(sw) 

    'Turn off the paging for export 
    Gridview1.DataSource = Session("dt") 
    Gridview1.AllowPaging = False 
    Gridview1.DataBind() 

    GridView1.RenderControl(htw) 
    Response.Write(sw.ToString()) 
    Response.[End]() 

    'Turn on the paging after export 
    Gridview1.DataSource = Session("dt") 
    Gridview1.AllowPaging = True 
    Gridview1.DataBind() 

End Sub 

答えて

0

//宣言<% = MyMethodCall()%:

おかげ ジョー

次は私のコードです。保護された文字列MyMethodCall(){戻り値 "テスト値"; }

関連する問題