locked
export nested datalist to Excel RRS feed

  • Question

  • User1363022477 posted

    Hi there,

     I am having nested datalist which shows reports in my web page and I am using DataSet for that.

    I would like to export to Excel.

    Could any one provide me some links or sample code for that? Thanks.

    Monday, January 26, 2009 6:22 PM

Answers

  • User1363022477 posted

    Hi there,

     I found some sample code and it is working fine, only thing is

    I am getting minus symbol in front of those numbers like

    100 % means I am getting -100% . Can any one tell me why?

    protected
    void Button1_Click1(object sender, EventArgs e)

    {

    Response.Clear();

    Response.Buffer =
    true;

    Response.ContentType = "application/vnd.ms-excel";

    Response.Charset = "";

    this.EnableViewState = false;

    System.IO.StringWriter oStringWriter = new System.IO.StringWriter();System.Web.UI.HtmlTextWriter oHtmlTextWriter = new System.Web.UI.HtmlTextWriter(oStringWriter);

    DataList2.RenderControl(oHtmlTextWriter);

    Response.Write(oStringWriter.ToString());

    Response.Flush();

    Response.End();

    }

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, January 26, 2009 8:12 PM