Help with exporting datagrid to excel

Posted on 2007-10-21
Last Modified: 2008-01-09
I have the following code and it doesn't work when I'm using a secure connection( https:// ). It works fine when the connection is unsecured (http://)

        Public Shared Sub ExportGridToExcel(ByVal sourceGrid As DataGrid, ByVal FileName As String)
            sourceGrid.GridLines = GridLines.Both
            sourceGrid.HeaderStyle.Font.Bold = True
            sourceGrid.HeaderStyle.ForeColor = Color.Black
            sourceGrid.HeaderStyle.BackColor = Color.Orange

            FileName = FileName.Replace(".xls", "")
            FileName &= ".xls"

            Dim Response As HttpResponse = HttpContext.Current.Response
            Response.AddHeader("content-disposition", "attachment;filename=" & FileName)
            Response.Charset = ""
            Response.ContentType = "application/vnd.xls"

            Dim stringWrite As New System.IO.StringWriter
            Dim htmlWrite As New HtmlTextWriter(stringWrite)


        End Sub
Question by:mattphung
    1 Comment
    LVL 22

    Accepted Solution

    Hi, comment out this line


    Take a look here for more info


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    How to quickly and accurately populate Word documents with Excel data, charts and images (including Automated Bookmark generation) David Miller (dlmille) Synopsis In this article you’ll learn how to use ExcelToWord! to copy data,charts, shapes …
    It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
    This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.
    This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now