Hi Samik,
What you really need it to apply a number format to all the cells you want
to have leading zeros. If you convert all numbers to strings, you will get
Excel "Number stored as text" warnings and that numbers will be treated as
text (and ignored in formulas).
You have few third-party components that can generate native XLS (together
with number format). If amount of data you are exporting is not large (less
than 5 sheets and 150 rows per sheet), you have our ExcelLite Free component
you can freely use in commercial apps. If your worksheet grows in size, you
can easily update to ExcelLite Professional. Check
http://www.gemboxsoftware.com for more information.
Jan
"samik_tanik" <sa*********@hotmail.com> wrote in message
news:6B**********************************@microsof t.com...
Hi Peter,
Thanks.
Yes, there are integer data.
I am creating the datagrid at runtime and render its data in html.
Please find the code snnipet as below:
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 = <datasource>
dg.DataBind()
dg.RenderControl(htmlWrite)
response.Write(stringWrite.ToString)
Please suggest how to honour the leading zeros.
Thanking you in anticipation,
Regards,
Samik.
"Peter van der Goes" wrote:
"samik_tanik" <sa*********@hotmail.com> wrote in message
news:D8**********************************@microsof t.com... >I need to export a datagrid to Excel.
> I could did this. But, also need to keep the leading
> zeros in the data.
> How can I acheive this?
>
> Any help would be appreciated.
>
> --
> Thanking you in anticipation,
> Regards,
> Samik.
Perhaps the following article and its references will help:
http://support.microsoft.com/default...b;en-us;317719
It sounds like you are trying to export a field containing numbers with
leading zeros and Excel is seeing it as a numeric field. To keep the
leading
zeros, you'll need to add string punctuation.