JDev

Code, .NETFebruary 12, 2009 8:18 pm

This solution was found on http://razvan.cosma.name/weblog/index.php?entry=entry090116-161656

private void ExportToExcel(string strFileName, GridView gv)
        {
            Response.ClearContent();
            Response.ContentType = "application/excel";
            Response.AddHeader("content-disposition", "attachment; filename=" + strFileName);
            Response.Charset = "";         
            Response.ContentEncoding = System.Text.Encoding.Unicode;
            Response.BinaryWrite(System.Text.Encoding.Unicode.GetPreamble());
            this.EnableViewState = false;
            System.IO.StringWriter sw = new System.IO.StringWriter();
            HtmlTextWriter htw = new HtmlTextWriter(sw);
            gv.RenderControl(htw);
            Response.Write(sw.ToString());    
            HttpContext.Current.ApplicationInstance.CompleteRequest();
        }

 

 

 

Code, javaFebruary 11, 2009 4:01 am

If you need to find text lines that start with an alphanumeric characters:

String reg ="\\w+";  

In other words, an alphanumeric character that gets repeated 1 or more times.

 To find text lines that start with a whitespace and contain other characters after it, use the following regex:

String  reg = "\\s.+";

 That is, first find a whitespace, then any character repeated 1 or more times.