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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Web Development
  3. ASP.NET
  4. Export with Style sheet from Datatable to excel

Export with Style sheet from Datatable to excel

Scheduled Pinned Locked Moved ASP.NET
questionhelp
6 Posts 2 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.
  • B Offline
    B Offline
    Biju Sam
    wrote on last edited by
    #1

    I have a dataview which when exported into excel shows in very small font. i want to apply style sheet before i export. How do i do it? Kindly help. Thanks & Regards Biju S

    V 1 Reply Last reply
    0
    • B Biju Sam

      I have a dataview which when exported into excel shows in very small font. i want to apply style sheet before i export. How do i do it? Kindly help. Thanks & Regards Biju S

      V Offline
      V Offline
      Venkatesh Mookkan
      wrote on last edited by
      #2

      Just the include your style inside a <STYLE> tag and append it with HTML String which you use to import as excel.

      Regards, Venkatesh Mookkan. Software Engineer, India My: Website | Yahoo Group | Blog Spot

      B 1 Reply Last reply
      0
      • V Venkatesh Mookkan

        Just the include your style inside a <STYLE> tag and append it with HTML String which you use to import as excel.

        Regards, Venkatesh Mookkan. Software Engineer, India My: Website | Yahoo Group | Blog Spot

        B Offline
        B Offline
        Biju Sam
        wrote on last edited by
        #3

        Thank you venkatesh. can you suggest me some sample code? i tried giving style but didnt work out

        V 1 Reply Last reply
        0
        • B Biju Sam

          Thank you venkatesh. can you suggest me some sample code? i tried giving style but didnt work out

          V Offline
          V Offline
          Venkatesh Mookkan
          wrote on last edited by
          #4

          Post your code where you export it. I will update the code.

          Regards, Venkatesh Mookkan. Software Engineer, India My: Website | Yahoo Group | Blog Spot

          B 1 Reply Last reply
          0
          • V Venkatesh Mookkan

            Post your code where you export it. I will update the code.

            Regards, Venkatesh Mookkan. Software Engineer, India My: Website | Yahoo Group | Blog Spot

            B Offline
            B Offline
            Biju Sam
            wrote on last edited by
            #5

            here is my code. Response.Clear(); gvCycleRpt.Columns[8].Visible = false; string style = @" .text { mso-number-format:\@; } "; Response.AddHeader("content-disposition", "attachment;filename=CycleReport.xls"); Response.Charset = ""; Response.ContentType = "application/vnd.xls"; StringWriter StringWriter = new System.IO.StringWriter(); HtmlTextWriter HtmlTextWriter = new HtmlTextWriter(StringWriter); gvCycleRpt.RenderControl(HtmlTextWriter); // Style is added dynamically Response.Write(style); Response.Write(StringWriter.ToString()); Response.End(); gvCycleRpt.Columns[8].Visible = true; Thanks & regards Biju S

            V 1 Reply Last reply
            0
            • B Biju Sam

              here is my code. Response.Clear(); gvCycleRpt.Columns[8].Visible = false; string style = @" .text { mso-number-format:\@; } "; Response.AddHeader("content-disposition", "attachment;filename=CycleReport.xls"); Response.Charset = ""; Response.ContentType = "application/vnd.xls"; StringWriter StringWriter = new System.IO.StringWriter(); HtmlTextWriter HtmlTextWriter = new HtmlTextWriter(StringWriter); gvCycleRpt.RenderControl(HtmlTextWriter); // Style is added dynamically Response.Write(style); Response.Write(StringWriter.ToString()); Response.End(); gvCycleRpt.Columns[8].Visible = true; Thanks & regards Biju S

              V Offline
              V Offline
              Venkatesh Mookkan
              wrote on last edited by
              #6

              itsbijusamuel wrote:

              Response.Clear(); gvCycleRpt.Columns[8].Visible = false; string style = @" .text { mso-number-format:\@; } "; Response.AddHeader("content-disposition", "attachment;filename=CycleReport.xls"); Response.Charset = ""; Response.ContentType = "application/vnd.xls"; StringWriter StringWriter = new System.IO.StringWriter(); HtmlTextWriter HtmlTextWriter = new HtmlTextWriter(StringWriter); gvCycleRpt.RenderControl(HtmlTextWriter); // Style is added dynamically Response.Write(style); Response.Write(StringWriter.ToString()); Response.End(); gvCycleRpt.Columns[8].Visible = true;

              Response.Clear(); gvCycleRpt.Columns[8].Visible = false; string style = @" .text { mso-number-format:\@; } "; Response.AddHeader("content-disposition", "attachment;filename=CycleReport.xls"); Response.Charset = ""; Response.ContentType = "application/vnd.xls"; StringWriter StringWriter = new System.IO.StringWriter(); HtmlTextWriter HtmlTextWriter = new HtmlTextWriter(StringWriter); gvCycleRpt.RenderControl(HtmlTextWriter); // Style is added dynamically StringBuilder sb = new StringBuilder(); sb.Append(style); sb.Append(StringWriter.ToString()); Response.Write(sb.ToString()); Response.End(); gvCycleRpt.Columns[8].Visible = true;

              Regards, Venkatesh Mookkan. Software Engineer, India My: Website | Yahoo Group | Blog Spot

              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