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 To Excel

Export To Excel

Scheduled Pinned Locked Moved ASP.NET
csharphelp
4 Posts 4 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.
  • Y Offline
    Y Offline
    yogesh_kumar_agarwal
    wrote on last edited by
    #1

    dear all i want to create a export button in my site by which all the record for the registered user stored in user table will exports into an excel file. how could i do taht help me for the same. i was created my site in C# language. With regards Yogesh Agarwal

    N J S 3 Replies Last reply
    0
    • Y yogesh_kumar_agarwal

      dear all i want to create a export button in my site by which all the record for the registered user stored in user table will exports into an excel file. how could i do taht help me for the same. i was created my site in C# language. With regards Yogesh Agarwal

      N Offline
      N Offline
      N a v a n e e t h
      wrote on last edited by
      #2

      You need to show data's need to be exported on a DataGrid. Say Datagrid1. Set the page response content type to excel. Using HTMLTextWriter to render the grid and write that to response. See the following code

      Response.ContentType = "application/vnd.ms-excel";
      Response.Charset = "";
      this.EnableViewState =false;
      System.IO.StringWriter ObjTextWriter= new System.IO.StringWriter();
      System.Web.UI.HtmlTextWriter ObjHTMLWriter= new System.Web.UI.HtmlTextWriter(ObjTextWriter);
      Datagrid1.RenderControl(ObjHTMLWriter);

      Hope this helps


      My Website | Ask smart questions

      1 Reply Last reply
      0
      • Y yogesh_kumar_agarwal

        dear all i want to create a export button in my site by which all the record for the registered user stored in user table will exports into an excel file. how could i do taht help me for the same. i was created my site in C# language. With regards Yogesh Agarwal

        J Offline
        J Offline
        John ph
        wrote on last edited by
        #3

        Export ASP.NET DataGrid to Excel[^]

        Regards
         - J O N -


        1 Reply Last reply
        0
        • Y yogesh_kumar_agarwal

          dear all i want to create a export button in my site by which all the record for the registered user stored in user table will exports into an excel file. how could i do taht help me for the same. i was created my site in C# language. With regards Yogesh Agarwal

          S Offline
          S Offline
          shanthivasan
          wrote on last edited by
          #4

          ReportDocument rpt=new ReportDocument(); rpt.Load(Server.MapPath("ReqVsCur.rpt")); rpt.SetDatabaseLogon("username","password"); rpt.SetParameterValue("@year",DateTime.Now.Year); MemoryStream oStream; oStream=(MemoryStream)rpt.ExportToStream(CrystalDecisions.Shared.ExportFormatType.Excel); Response.Clear(); Response.Buffer=true; Response.ContentType="application/vnd.msexcel"; Response.BinaryWrite(oStream.ToArray()); Response.End();

          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