html to Excel


        public void button_click_Excel(object sender, EventArgs e) {

            Response.Clear();
            Response.ClearHeaders();
            Response.ClearContent();
            Response.ContentType = "application/force-download";
            Response.AddHeader("content-disposition", "attachment; filename=Print.xls");
            Response.Write("");
            Response.Write("");
            Response.Write("");
            Response.Write(" ");
            Response.Write(this.htmlData());
            Response.Write("
");            Response.Flush();
        }





        public string htmlData() {

            string data = "";
            Reporting dataCenter = new Reporting();
            rowList = dataCenter.getData("basis", 6, "SLA_Einhaltung");
            //Multi Dimension Array into DataTable
            data +="";

            for (int outerIndex = 0; outerIndex < rowList.GetLength(0); outerIndex++)
            {
                data += " ";
                for (int innerIndex = 0; innerIndex < rowList.GetLength(1); innerIndex++)
                {
                    data += "";
                    data += rowList.GetValue(outerIndex, innerIndex);
                    data += "
";                }
                data += "
";            }
            data +="
";            return data;
        }

Comments

Popular posts from this blog

like php