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