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. Zeros doesnt get displayed in my vb.net application...

Zeros doesnt get displayed in my vb.net application...

Scheduled Pinned Locked Moved ASP.NET
csharphtmldatabasedotnet
2 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.
  • T Offline
    T Offline
    Tash18
    wrote on last edited by
    #1

    Hi guys.. In my web application which is on vb.net framework1.1 VS2003, Im actually populating an HTML table based on the records retrieved from the database.. Now above the Table I have a button on clicking it the table gets exported to Excel.. Heres the issue.. now in my table i display Userid which is for example: 001258, 001259 etc.. while displaying it on the table its fine but while exporting it to excel my userid on the excel sheet gets changed from 001258 to 1258 the issue is all the zeros present at the beginning gets vanished.. The code that i use for exporting the table to Excel is as follows:

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnExp.Click
    'I have stored My dataset 'DS' in Session("app")
    DataSetToExcel.Convert(Session("app"), Response)

    End Sub
    
        Public Shared Sub Convert(ByVal ds As DataSet, ByVal response As HttpResponse)
            response.Clear()
            response.Charset = ""
            response.ContentType = "application/vnd.ms-excel"
            Dim stringWrite As New System.IO.StringWriter
            Dim htmlWrite As New System.Web.UI.HtmlTextWriter(stringWrite)
            Dim dg As New DataGrid
            dg.DataSource = ds.Tables(0)
            dg.DataBind()
            dg.RenderControl(htmlWrite)
            response.Write(stringWrite.ToString)
            response.End()
        End Sub
    

    Do please Advice me reagarding this issue... Mean while im also googling it out.. Thanx in advance... Tash

    N 1 Reply Last reply
    0
    • T Tash18

      Hi guys.. In my web application which is on vb.net framework1.1 VS2003, Im actually populating an HTML table based on the records retrieved from the database.. Now above the Table I have a button on clicking it the table gets exported to Excel.. Heres the issue.. now in my table i display Userid which is for example: 001258, 001259 etc.. while displaying it on the table its fine but while exporting it to excel my userid on the excel sheet gets changed from 001258 to 1258 the issue is all the zeros present at the beginning gets vanished.. The code that i use for exporting the table to Excel is as follows:

      Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnExp.Click
      'I have stored My dataset 'DS' in Session("app")
      DataSetToExcel.Convert(Session("app"), Response)

      End Sub
      
          Public Shared Sub Convert(ByVal ds As DataSet, ByVal response As HttpResponse)
              response.Clear()
              response.Charset = ""
              response.ContentType = "application/vnd.ms-excel"
              Dim stringWrite As New System.IO.StringWriter
              Dim htmlWrite As New System.Web.UI.HtmlTextWriter(stringWrite)
              Dim dg As New DataGrid
              dg.DataSource = ds.Tables(0)
              dg.DataBind()
              dg.RenderControl(htmlWrite)
              response.Write(stringWrite.ToString)
              response.End()
          End Sub
      

      Do please Advice me reagarding this issue... Mean while im also googling it out.. Thanx in advance... Tash

      N Offline
      N Offline
      Not Active
      wrote on last edited by
      #2

      There is no issue. Excel sees this as a number and will truncate the leading zeros by default. Change the formatting of the cells in the Excel spreadsheet.


      I know the language. I've read a book. - _Madmatt

      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