Friday, 1 September 2017

Export HTML String In Excel

protected void BtnExport_OnClick(object sender, EventArgs e)
    {
        try
        {
            StringBuilder sb = new StringBuilder();
            sb.Append("<table width='100%' border='1' cellpadding='7' cellspacing='0' style='font: normal 13px/20px Arial, Helvetica, sans-serif'>");
            sb.Append("<tr>");
            sb.Append("<td align='left' style='background:#E5E5E5;' valign='top' colspan='4'><b>Test</b></td>");
            sb.Append("</tr>");          
            sb.Append("</table>");

            Response.Clear();
            Response.Buffer = true;
            Response.AddHeader("content-disposition", "attachment;filename="Test.xls");
            Response.Charset = "";
            Response.ContentType = "application/vnd.ms-excel";
            using (StringWriter sw = new StringWriter())
            {
                HtmlTextWriter hw = new HtmlTextWriter(sw);
                Response.Output.Write(sb.ToString());
                Response.Flush();
                Response.SuppressContent = true;
            }
        }
        catch (Exception ex)
        {
            CommonFunction.SiteErrorInsert(ex);
        }
    }

React Hooks - custom Hook

  v CustomHook Ø React allows us to create our own hook which is known as custom hook. Example – 1 localStorage Demo Step-1 Create ...