up

解决方案 »

  1.   

    直接url指向一个excel就行了吧
      

  2.   

    Response.ClearContent()
    Response.ClearHeaders()
    Response.ContentType = "application/vnd.ms-excel"       
    Response.AddHeader("Content-Disposition", "inline;filename='你的文件名'" )
    Response.WriteFile("你的excel文件地址")
    Response.Flush()
    Response.Close()这样就能写到页面上了
      

  3.   

    如果是服务器端存在这个excel的话直接做个超链指向这个excel文件即可,如果服务器端不存在这个excel即你需要向客户端输出的话则使用下边的方法既可
    从datagrid中生成excel
    'Dim oStringWriter As System.IO.StringWriter
            'Dim oHtmlTextWriter As System.Web.UI.HtmlTextWriter
            'Response.Clear()
            'Response.Buffer = True
            'Response.Charset = "GB2312"
            'Response.AppendHeader("Content-Disposition", "attachment;filename=abc.xls")
            'Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312")
            'Response.ContentType = "application/ms-excel"
            'Me.EnableViewState = False
            'oStringWriter = New System.IO.StringWriter
            'oHtmlTextWriter = New System.Web.UI.HtmlTextWriter(oStringWriter)
            'DataGrid1.RenderControl(oHtmlTextWriter)
            'Response.Write(oStringWriter.ToString())
            'Response.End()如果你不想用url的话也可以用文件输出的方式
    'Dim fullName As String        'fullName = "c:\\abc.xls"
            'Response.ClearHeaders()
            'Response.BufferOutput = False
            'Response.ContentType = "application/octet-stream"
            'Response.AppendHeader("Content-disposition", "attachment;filename=abc.xls")
            'Response.WriteFile(fullName)
            'Response.Flush()
            'Response.End()