Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Export data to Excel problem

Export data to Excel problem

Scheduled Pinned Locked Moved ASP.NET
helptutorialquestion
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Asif Rehman
    wrote on last edited by
    #1

    Following code does not handle columns that start with +. for example, '+923339933886' is not rendered well(some kind of charmap characters shown).

        HtmlForm form = new HtmlForm();
        string attachment = "attachment; filename=Employee.xls";
        Response.ClearContent();
        Response.AddHeader("content-disposition", attachment);
        Response.ContentType = "application/ms-excel";
        StringWriter stw = new StringWriter();
        HtmlTextWriter htextw = new HtmlTextWriter(stw);
        form.Controls.Add(gvEmployee);
        this.Controls.Add(form);
        form.RenderControl(htextw);
        Response.Write(stw.ToString());
        Response.End();
    

    Please let me know what is the changes required in this code.

    H T 2 Replies Last reply
    0
    • A Asif Rehman

      Following code does not handle columns that start with +. for example, '+923339933886' is not rendered well(some kind of charmap characters shown).

          HtmlForm form = new HtmlForm();
          string attachment = "attachment; filename=Employee.xls";
          Response.ClearContent();
          Response.AddHeader("content-disposition", attachment);
          Response.ContentType = "application/ms-excel";
          StringWriter stw = new StringWriter();
          HtmlTextWriter htextw = new HtmlTextWriter(stw);
          form.Controls.Add(gvEmployee);
          this.Controls.Add(form);
          form.RenderControl(htextw);
          Response.Write(stw.ToString());
          Response.End();
      

      Please let me know what is the changes required in this code.

      H Offline
      H Offline
      Hiren solanki
      wrote on last edited by
      #2

      Are you sure you will get a better response this time then That[^]?

      Regards, Hiren.

      My Recent Article: - Way to know which control have raised a postback
      My Recent Tip/Trick: - Remove HTML Tag, get plain Text

      1 Reply Last reply
      0
      • A Asif Rehman

        Following code does not handle columns that start with +. for example, '+923339933886' is not rendered well(some kind of charmap characters shown).

            HtmlForm form = new HtmlForm();
            string attachment = "attachment; filename=Employee.xls";
            Response.ClearContent();
            Response.AddHeader("content-disposition", attachment);
            Response.ContentType = "application/ms-excel";
            StringWriter stw = new StringWriter();
            HtmlTextWriter htextw = new HtmlTextWriter(stw);
            form.Controls.Add(gvEmployee);
            this.Controls.Add(form);
            form.RenderControl(htextw);
            Response.Write(stw.ToString());
            Response.End();
        

        Please let me know what is the changes required in this code.

        T Offline
        T Offline
        thatraja
        wrote on last edited by
        #3

        Check my answer here[^] for your question. BTW please wait for the replies don't post duplicate questions. cheers.

        thatraja |Chennai|India|


        Brainbench certifications
        My Dad had a Heart Attack on this day so don't...

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups