How to export into Excel in asp.net 1.1 with proper formatting
-
Hi, I have used the Response method for exporting to excel sheet. The Date field values are displayed not properly . Snapshot of the code which I used: Response.Clear() Response.Buffer = True Response.ContentType = "application/vnd.ms-excel" Response.AddHeader("Content-Disposition", "attachment; filename=""" & strFileName & """") Response.Charset = "" Response.Cache.SetCacheability(HttpCacheability.NoCache) Me.EnableViewState = False Dim oStringWriter As New System.IO.StringWriter Dim oHtmlTextWriter As New System.Web.UI.HtmlTextWriter(oStringWriter) Dim a As New System.Web.UI.HtmlTextWriterStyle Excelgrid.RenderControl(oHtmlTextWriter) Dim sExcel As String sExcel &= oStringWriter.ToString() Response.Write(sExcel) Response.End() My requirement is Date to be displayed in dd/MM/yyyy format. But in exported excel sheet, some values are treated as Date and others (it assumes the first 'Date' part as month and if it is greater than 12, it treats as String instead of Date) What way I can solve this problem. Any possibility to formatting the columns in excel thru coding and what else can I do to get the values properly. Expecting ur swift reponse. I need solution for this as soon as possible coz I was dragging with the issue for past 3 days and not find any solution. :(
Thankfully, jm