Tuesday, 24 March 2015

Show Number formate Columns to Text formate in excel export in asp.net, C#



            string datestyle = @"<style> .nf{mso-number-format:\@;}</style>";

//add this string to your export data table
            HttpResponse Response = HttpContext.Current.Response;
            string filename = "Test" + "_" + System.DateTime.Now.ToString("MMddyy_hhmmss") + ".doc";
            Response.Clear();
            Response.AddHeader("content-disposition""attachment;filename=" + filename);
            Response.Charset = "";
            Response.ContentType = "application/xls";
            System.IO.StringWriter WriteItem = new System.IO.StringWriter();
            System.Web.UI.HtmlTextWriter htmlText = newHtmlTextWriter(WriteItem);

            Response.Write(datestyle);
            Response.Write(strBuilder.ToString());
            Response.End();

No comments:

Post a Comment

How to highlight selected text in notepad++

  –> To highlight a block of code in Notepad++, please do the following steps step-1  :- Select the required text. step-2  :- Right click...