protected void btnexportcsv_Click(object sender, EventArgs e)
        {
            DataTable     dt = new DataTable();
            StringBuilder sb = new StringBuilder();

            bindheader();
            fillgrid();
            if (ds.Tables[0].Rows.Count > 0)
            {
                sb.Append("<table cellpadding='4' cellspacing='0' style='font-family:Calibri;font-size:12px;' border='0'>" + bindheader() + "<tr><th style='text-align:center;'>S.No.</th><th  style='text-align:left;'>Client Code</th><th style='text-align:left;'>Client Name</th><th style='text-align:left;'>Contact Name</th><th style='text-align:left;'>Email Id</th><th style='text-align:left;'>Phone</th><th style='text-align:left;'>Cell</th><th style='text-align:left;'>Fax</th><th style='text-align:left;'>Website</th><th style='text-align:left;'>Address</th><th style='text-align:left;'>City</th><th style='text-align:left;'>State</th><th style='text-align:left;'>Country</th><th style='text-align:left;'>ZIP</th><th style='text-align:left;'>Manager</th><th style='text-align:left;'>Active Status</th></tr>");

                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    if (ds.Tables[0].Rows[i]["activestatus"].ToString().ToLower() == "block")
                    {
                        sb.Append("<tr style= 'color:red;'><td style='text-align:center;'>" + (i + 1).ToString() + "</td><td>" + ds.Tables[0].Rows[i]["code"].ToString() + "</td><td>" + ds.Tables[0].Rows[i]["clientname"].ToString() + "</td><td>" + ds.Tables[0].Rows[i]["company"].ToString() + "</td><td>" + ds.Tables[0].Rows[i]["email"].ToString() + "</td><td>" + ds.Tables[0].Rows[i]["phone"].ToString() + "</td><td>" + ds.Tables[0].Rows[i]["mobile"].ToString() + "</td><td>" + ds.Tables[0].Rows[i]["fax"].ToString() + "</td><td>" + ds.Tables[0].Rows[i]["website"].ToString() + "</td><td>" + ds.Tables[0].Rows[i]["street"].ToString() + "</td><td>" + ds.Tables[0].Rows[i]["city"].ToString() + "</td><td>" + ds.Tables[0].Rows[i]["state"].ToString() + "</td><td>" + ds.Tables[0].Rows[i]["country"].ToString() + "</td><td>" + ds.Tables[0].Rows[i]["zip"].ToString() + "</td><td>" + ds.Tables[0].Rows[i]["managername"].ToString() + "</td><td>" + ds.Tables[0].Rows[i]["activestatus"].ToString() + "</td></tr>");
                    }
                    else
                    {
                        sb.Append("<tr><td style='text-align:center;'>" + (i + 1).ToString() + "</td><td>" + ds.Tables[0].Rows[i]["code"].ToString() + "</td><td>" + ds.Tables[0].Rows[i]["clientname"].ToString() + "</td><td>" + ds.Tables[0].Rows[i]["company"].ToString() + "</td><td>" + ds.Tables[0].Rows[i]["email"].ToString() + "</td><td>" + ds.Tables[0].Rows[i]["phone"].ToString() + "</td><td>" + ds.Tables[0].Rows[i]["mobile"].ToString() + "</td><td>" + ds.Tables[0].Rows[i]["fax"].ToString() + "</td><td>" + ds.Tables[0].Rows[i]["website"].ToString() + "</td><td>" + ds.Tables[0].Rows[i]["street"].ToString() + "</td><td>" + ds.Tables[0].Rows[i]["city"].ToString() + "</td><td>" + ds.Tables[0].Rows[i]["state"].ToString() + "</td><td>" + ds.Tables[0].Rows[i]["country"].ToString() + "</td><td>" + ds.Tables[0].Rows[i]["zip"].ToString() + "</td><td>" + ds.Tables[0].Rows[i]["managername"].ToString() + "</td><td>" + ds.Tables[0].Rows[i]["activestatus"].ToString() + "</td></tr>");
                    }
                }
                sb.Append("</table>");
            }

            excelexport objexcel = new excelexport();

            objexcel.downloadFile(sb.ToString(), "Client.xls");
        }
        protected void btnexportcsv_Click(object sender, EventArgs e)
        {
            DataTable     dt = new DataTable();
            StringBuilder sb = new StringBuilder();

            bindheader();
            fillgrid();
            if (ds.Tables[0].Rows.Count > 0)
            {
                sb.Append("<table cellpadding='4' cellspacing='0' style='font-family:Calibri;font-size:12px;' border='0'>" + bindheader() + "<tr><th style='text-align:center;'>S.No.</th><th style='text-align:left;'>Emp ID</th><th style='text-align:left;'>Emp Name</th><th style='text-align:left;'>Email</th><th style='text-align:left;'>Designation</th><th style='text-align:left;'>Department</th><th style='text-align:left;'>Join Date</th><th style='text-align:left;'>Released Date</th><th style='text-align:left;'>Active Status</th></tr>");

                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    if (ds.Tables[0].Rows[i]["activestatus"].ToString().ToLower() == "block")
                    {
                        sb.Append("<tr  style= 'color:red;'><td style='text-align:center;'>" + (i + 1).ToString() + "</td><td>" + ds.Tables[0].Rows[i]["loginid"].ToString() + "</td><td>" + ds.Tables[0].Rows[i]["fname"].ToString() + " " + ds.Tables[0].Rows[i]["lname"].ToString() + "</td><td>" + ds.Tables[0].Rows[i]["emailid"].ToString() + "</td><td>" + ds.Tables[0].Rows[i]["designation"].ToString() + "</td><td>" + ds.Tables[0].Rows[i]["department"].ToString() + "</td><td>" + ds.Tables[0].Rows[i]["joindate"].ToString() + "</td><td>" + ds.Tables[0].Rows[i]["releaseddate"].ToString() + "</td><td>" + ds.Tables[0].Rows[i]["activestatus"].ToString() + "</td></tr>");
                    }
                    else
                    {
                        sb.Append("<tr><td style='text-align:center;'>" + (i + 1).ToString() + "</td><td>" + ds.Tables[0].Rows[i]["loginid"].ToString() + "</td><td>" + ds.Tables[0].Rows[i]["fname"].ToString() + " " + ds.Tables[0].Rows[i]["lname"].ToString() + "</td><td>" + ds.Tables[0].Rows[i]["emailid"].ToString() + "</td><td>" + ds.Tables[0].Rows[i]["designation"].ToString() + "</td><td>" + ds.Tables[0].Rows[i]["department"].ToString() + "</td><td>" + ds.Tables[0].Rows[i]["joindate"].ToString() + "</td><td>" + ds.Tables[0].Rows[i]["releaseddate"].ToString() + "</td><td>" + ds.Tables[0].Rows[i]["activestatus"].ToString() + "</td></tr>");
                    }
                }
                sb.Append("</table>");
            }

            excelexport objexcel = new excelexport();

            objexcel.downloadFile(sb.ToString(), "Employee.xls");
        }
        protected void btnexportcsv_Click(object sender, EventArgs e)
        {
            DataTable     dt  = new DataTable();
            StringBuilder sb  = new StringBuilder();
            StringBuilder sb1 = new StringBuilder();

            bindheader();
            fillgrid();
            if (ds.Tables[0].Rows.Count > 0)
            {
                sb.Append("<table cellpadding='4' cellspacing='0' style='font-family:Calibri;font-size:12px;' border='0'>" + bindheader());
                for (int i = 0; i < dgnews.Columns.Count; i++)
                {
                }
                sb.Append("<tr><th>Category Name</th></tr>");
                for (int j = 0; j < ds.Tables[0].Rows.Count; j++)
                {
                    sb.Append("<tr>");

                    //for (int i = 0; i < ds.Tables[0].Columns.Count; i++)
                    {
                        sb.Append("<td>" + ds.Tables[0].Rows[j][2].ToString() + "</td>");
                    }
                    sb.Append("</tr>");
                }
                sb.Append("</table>");
            }



            excelexport objexcel = new excelexport();

            objexcel.downloadFile(sb.ToString(), "FileCategories.xls");
        }
        protected void btnexportcsv_Click(object sender, EventArgs e)
        {
            fillgrid();


            excelexport objexcel = new excelexport();

            objexcel.downloadFile(sb.ToString(), "EmployeeAttendance.xls");
        }
        private void downloadfile()
        {
            excelexport objexcel = new excelexport();

            if (!objexcel.downloadVirturalfile(Request.QueryString["file1"].ToString(), Request.QueryString["file2"].ToString(), "webfile/attachfiles"))
            {
                ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "temp", "<script type='text/javascript'>alert('File is not available or temporarily removed.');window.close(); </script>", false);
                return;
            }
        }
Beispiel #6
0
        protected void btnexportcsv_Click(object sender, EventArgs e)
        {
            DataTable     dt = new DataTable();
            StringBuilder sb = new StringBuilder();

            bindheader();
            fillgrid();
            if (ds.Tables[0].Rows.Count > 0)
            {
                sb.Append("<table cellpadding='4' cellspacing='0' style='font-family:Calibri;font-size:12px;' border='0'>" + bindheader() + "<tr><th style='text-align:center;'>S.No.</th><th  style='text-align:left;'>Project Code</th><th style='text-align:left;'>Project Name</th><th style='text-align:left;'>Client Code</th><th style='text-align:left;'>Client Name</th><th>Manager</th><th>Contract Type</th><th>Project Status</th> <th>Contract Amount</th><th>Service Amount</th><th>Exp Amount</th><th>Complete Percent</th><th>Creation Date</th><th>Start Date</th><th>Due Date</th></tr>");

                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    if (ds.Tables[0].Rows[i]["projectstatus"].ToString().ToLower() == "block")
                    {
                        sb.Append("<tr style= 'color:red;'><td style='text-align:center;'>" + (i + 1).ToString() + "</td><td>" + ds.Tables[0].Rows[i]["projectCode"].ToString() + "</td><td>" + ds.Tables[0].Rows[i]["projectname"].ToString() + "</td><td>" + ds.Tables[0].Rows[i]["clientcode"].ToString() + "</td><td>" + ds.Tables[0].Rows[i]["clientname"].ToString() + "</td><td>" + ds.Tables[0].Rows[i]["empname"].ToString() + "</td><td>" + ds.Tables[0].Rows[i]["contractType"].ToString() + "</td><td>" + ds.Tables[0].Rows[i]["projectStatus"].ToString() + "</td><td>" + ds.Tables[0].Rows[i]["contractAmt"].ToString() + "</td><td>" + ds.Tables[0].Rows[i]["serviceAmt"].ToString() + "</td><td>" + ds.Tables[0].Rows[i]["expAmt"].ToString() + "</td><td>" + ds.Tables[0].Rows[i]["completePercent"].ToString() + "</td><td>" + ds.Tables[0].Rows[i]["creationDate"].ToString() + "</td><td>" + ds.Tables[0].Rows[i]["startDate"].ToString() + "</td><td>" + ds.Tables[0].Rows[i]["dueDate"].ToString() + "</td></tr>");
                    }
                    else
                    {
                        sb.Append("<tr><td style='text-align:center;'>" + (i + 1).ToString() + "</td><td>" + ds.Tables[0].Rows[i]["projectCode"].ToString() + "</td><td>" + ds.Tables[0].Rows[i]["projectname"].ToString() + "</td><td>" + ds.Tables[0].Rows[i]["clientcode"].ToString() + "</td><td>" + ds.Tables[0].Rows[i]["clientname"].ToString() + "</td><td>" + ds.Tables[0].Rows[i]["empname"].ToString() + "</td><td>" + ds.Tables[0].Rows[i]["contractType"].ToString() + "</td><td>" + ds.Tables[0].Rows[i]["projectStatus"].ToString() + "</td><td>" + ds.Tables[0].Rows[i]["contractAmt"].ToString() + "</td><td>" + ds.Tables[0].Rows[i]["serviceAmt"].ToString() + "</td><td>" + ds.Tables[0].Rows[i]["expAmt"].ToString() + "</td><td>" + ds.Tables[0].Rows[i]["completePercent"].ToString() + "</td><td>" + ds.Tables[0].Rows[i]["creationDate"].ToString() + "</td><td>" + ds.Tables[0].Rows[i]["startDate"].ToString() + "</td><td>" + ds.Tables[0].Rows[i]["dueDate"].ToString() + "</td></tr>");
                    }
                }
                sb.Append("</table>");
            }
            //using (XLWorkbook wb = new XLWorkbook())
            //{
            //    wb.Worksheets.Add(ds.Tables[0]);

            //    Response.Clear();
            //    Response.Buffer = true;
            //    Response.Charset = "";
            //    Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
            //    Response.AddHeader("content-disposition", "attachment;filename=GridView.xlsx");
            //    using (MemoryStream MyMemoryStream = new MemoryStream())
            //    {
            //        wb.SaveAs(MyMemoryStream);
            //        MyMemoryStream.WriteTo(Response.OutputStream);
            //        Response.Flush();
            //        Response.End();
            //    }
            //}
            //Response.AppendHeader("content-disposition", "attachment;filename=ExportedHtml.xls");
            //Response.Charset = "";
            //Response.Cache.SetCacheability(HttpCacheability.NoCache);
            //Response.ContentType = "application/vnd.ms-excel";
            //this.EnableViewState = false;
            //Response.Write(sb.ToString());
            //Response.End();
            excelexport objexcel = new excelexport();

            objexcel.downloadFile(sb.ToString(), "Projects.xls");
        }
Beispiel #7
0
        protected void btnexportcsv_Click(object sender, EventArgs e)
        {
            fillgrid();
            string rpthtml = bindheader("excel");

            for (int i = 0; i < dsexcel.Tables[0].Rows.Count; i++)
            {
                rpthtml = rpthtml + "<tr " + (Convert.ToBoolean(dsexcel.Tables[0].Rows[i]["isbillable"]) == true ? "" : " style='color:red;' ") + "><td>" + Convert.ToString(i + 1) + "</td>" + "<td>" + dsexcel.Tables[0].Rows[i]["date"].ToString() +
                          "</td><td>" + dsexcel.Tables[0].Rows[i]["empname"].ToString()
                          + "</td><td>" + dsexcel.Tables[0].Rows[i]["projectcode"].ToString() + "</td><td>" + dsexcel.Tables[0].Rows[i]["projectname"].ToString() + "</td><td>" + dsexcel.Tables[0].Rows[i]["taskcodenamesmall"].ToString() + "</td><td>" + dsexcel.Tables[0].Rows[i]["hours"].ToString() + "</td><td>" + dsexcel.Tables[0].Rows[i]["description"].ToString() + "</td><td>" + (Convert.ToBoolean(dsexcel.Tables[0].Rows[i]["isbillable"]) == true ? "Yes" : "No") + "</td><td>" + dsexcel.Tables[0].Rows[i]["taskstatus"].ToString() + "</td><td>" + dsexcel.Tables[0].Rows[i]["memo"].ToString() + "</td></tr>";
            }

            excelexport objexcel = new excelexport();

            objexcel.downloadFile(rpthtml.ToString(), "TimeEntry.xls");
        }