Beispiel #1
0
        protected void ibExcel_Click(object sender, ImageClickEventArgs e)
        {
            int    PesoTotalOrig = 0;
            string f1            = "";
            string f2            = "";

            if (txtFechaInicio.Text != "" && txtFechaTermino.Text != "")
            {
                string   fechaI = txtFechaInicio.Text;
                string[] str    = fechaI.Split('/');
                string   dia    = str[0];
                string   mes    = str[1];
                string   año    = str[2];
                año = año.Substring(0, 4);

                string fechaInicio = mes + "/" + dia + "/" + año;

                f1 = fechaInicio;

                string   fechaT = txtFechaTermino.Text;
                string[] str2   = fechaT.Split('/');
                string   dia2   = str2[0];
                string   mes2   = str2[1];
                string   año2   = str2[2];
                año = año.Substring(0, 4);

                string fechaTermino = mes2 + "/" + dia2 + "/" + año2;

                f2 = fechaTermino;
            }
            else
            {
                f1 = DateTime.Now.AddDays(-1).ToString("MM/dd/yyyy");
                f2 = DateTime.Now.AddDays(-30).ToString("MM/dd/yyyy");
            }
            HttpResponse        response     = Response;
            StringWriter        sw           = new StringWriter();
            HtmlTextWriter      htw          = new HtmlTextWriter(sw);
            Page                pageToRender = new Page();
            HtmlForm            form         = new HtmlForm();
            Label               la           = new Label();
            Bobina_Controller   controlb     = new Bobina_Controller();
            List <Inf_Regional> lista        = controlb.List_Inf_Regional(f1, f2);

            PesoTotalOrig = controlb.PesoOriginalTB(f1, f2);
            List <Inf_Regional> lista1  = lista.Where(o => o.Maquina.Substring(0, 3).ToUpper() != "WEB" && o.Turno == "Mañana" && o.Maquina != "General").ToList();
            Inf_Regional        TTurnoR = new Inf_Regional();
            int CantidadBob             = 0;

            foreach (Inf_Regional x in lista1)
            {
                CantidadBob        = CantidadBob + (Convert.ToInt32(x.BobBueCant) + Convert.ToInt32(x.BobDetCant) + Convert.ToInt32(x.BobOtrCant) + Convert.ToInt32(x.BobRotCant));
                TTurnoR.Maquina    = "T. Turno";
                TTurnoR.BobBueCant = (Convert.ToInt32(x.BobBueCant) + Convert.ToInt32(TTurnoR.BobBueCant)).ToString(); TTurnoR.BobBueEsc = (Convert.ToDouble(x.BobBueEsc) + Convert.ToDouble(TTurnoR.BobBueEsc)).ToString();
                TTurnoR.BobDetCant = (Convert.ToInt32(x.BobDetCant) + Convert.ToInt32(TTurnoR.BobDetCant)).ToString(); TTurnoR.BobDetEsc = (Convert.ToDouble(x.BobDetEsc) + Convert.ToDouble(TTurnoR.BobDetEsc)).ToString();
                TTurnoR.BobOtrCant = (Convert.ToInt32(x.BobOtrCant) + Convert.ToInt32(TTurnoR.BobOtrCant)).ToString(); TTurnoR.BobOtrEsc = (Convert.ToDouble(x.BobOtrEsc) + Convert.ToDouble(TTurnoR.BobOtrEsc)).ToString();
                TTurnoR.BobRotCant = (Convert.ToInt32(x.BobRotCant) + Convert.ToInt32(TTurnoR.BobRotCant)).ToString(); TTurnoR.BobRotEsc = (Convert.ToDouble(x.BobRotEsc) + Convert.ToDouble(TTurnoR.BobRotEsc)).ToString();
            }
            if (TTurnoR.BobBueCant != "0")
            {
                TTurnoR.BobBueProm = (Convert.ToDouble(TTurnoR.BobBueEsc) / Convert.ToInt32(TTurnoR.BobBueCant)).ToString("N1");
                TTurnoR.BobBueProG = ((Convert.ToDouble(TTurnoR.BobBueCant) / CantidadBob) * 100).ToString("N2");
            }
            else
            {
                TTurnoR.BobBueProm = "0"; TTurnoR.BobBueProG = "0.00";
            }
            if (TTurnoR.BobDetCant != "0")
            {
                TTurnoR.BobDetProm = (Convert.ToDouble(TTurnoR.BobDetEsc) / Convert.ToInt32(TTurnoR.BobDetCant)).ToString("N1");
                TTurnoR.BobDetProG = ((Convert.ToDouble(TTurnoR.BobDetCant) / CantidadBob) * 100).ToString("N2");
            }
            else
            {
                TTurnoR.BobDetProm = "0"; TTurnoR.BobDetProG = "0.00";
            }
            if (TTurnoR.BobOtrCant != "0")
            {
                TTurnoR.BobOtrProm = (Convert.ToDouble(TTurnoR.BobOtrEsc) / Convert.ToInt32(TTurnoR.BobOtrCant)).ToString("N1");
                TTurnoR.BobOtrProG = ((Convert.ToDouble(TTurnoR.BobOtrCant) / CantidadBob) * 100).ToString("N2");
            }
            else
            {
                TTurnoR.BobOtrProm = "0"; TTurnoR.BobOtrProG = "0.00";
            }
            if (TTurnoR.BobRotCant != "0")
            {
                TTurnoR.BobRotProm = (Convert.ToDouble(TTurnoR.BobRotEsc) / Convert.ToInt32(TTurnoR.BobRotCant)).ToString("N1");
                TTurnoR.BobRotProG = ((Convert.ToDouble(TTurnoR.BobRotCant) / CantidadBob) * 100).ToString("N2");
            }
            else
            {
                TTurnoR.BobRotProm = "0"; TTurnoR.BobRotProG = "0.00";
            }

            lista1.Add(TTurnoR);
            List <Inf_Regional> lista2   = lista.Where(o => o.Maquina.ToUpper() != "WEB 1" && o.Turno == "Tarde" && o.Maquina != "General" && o.Maquina.ToUpper() != "WEB 2").ToList();
            Inf_Regional        TTurnoR2 = new Inf_Regional();
            int CantidadBob2             = 0;

            foreach (Inf_Regional x in lista2)
            {
                CantidadBob2        = CantidadBob2 + (Convert.ToInt32(x.BobBueCant) + Convert.ToInt32(x.BobDetCant) + Convert.ToInt32(x.BobOtrCant) + Convert.ToInt32(x.BobRotCant));
                TTurnoR2.Maquina    = "T. Turno";
                TTurnoR2.BobBueCant = (Convert.ToInt32(x.BobBueCant) + Convert.ToInt32(TTurnoR2.BobBueCant)).ToString(); TTurnoR2.BobBueEsc = (Convert.ToDouble(x.BobBueEsc) + Convert.ToDouble(TTurnoR2.BobBueEsc)).ToString();
                TTurnoR2.BobDetCant = (Convert.ToInt32(x.BobDetCant) + Convert.ToInt32(TTurnoR2.BobDetCant)).ToString(); TTurnoR2.BobDetEsc = (Convert.ToDouble(x.BobDetEsc) + Convert.ToDouble(TTurnoR2.BobDetEsc)).ToString();
                TTurnoR2.BobOtrCant = (Convert.ToInt32(x.BobOtrCant) + Convert.ToInt32(TTurnoR2.BobOtrCant)).ToString(); TTurnoR2.BobOtrEsc = (Convert.ToDouble(x.BobOtrEsc) + Convert.ToDouble(TTurnoR2.BobOtrEsc)).ToString();
                TTurnoR2.BobRotCant = (Convert.ToInt32(x.BobRotCant) + Convert.ToInt32(TTurnoR2.BobRotCant)).ToString(); TTurnoR2.BobRotEsc = (Convert.ToDouble(x.BobRotEsc) + Convert.ToDouble(TTurnoR2.BobRotEsc)).ToString();
            }
            if (TTurnoR2.BobBueCant != "0")
            {
                TTurnoR2.BobBueProm = (Convert.ToDouble(TTurnoR2.BobBueEsc) / Convert.ToInt32(TTurnoR2.BobBueCant)).ToString("N1");
                TTurnoR2.BobBueProG = ((Convert.ToDouble(TTurnoR2.BobBueCant) / CantidadBob2) * 100).ToString("N2");
            }
            else
            {
                TTurnoR2.BobBueProm = "0"; TTurnoR2.BobBueProG = "0.00";
            }
            if (TTurnoR2.BobDetCant != "0")
            {
                TTurnoR2.BobDetProm = (Convert.ToDouble(TTurnoR2.BobDetEsc) / Convert.ToInt32(TTurnoR2.BobDetCant)).ToString("N1");
                TTurnoR2.BobDetProG = ((Convert.ToDouble(TTurnoR2.BobDetCant) / CantidadBob2) * 100).ToString("N2");
            }
            else
            {
                TTurnoR2.BobDetProm = "0"; TTurnoR2.BobDetProG = "0.00";
            }
            if (TTurnoR2.BobOtrCant != "0")
            {
                TTurnoR2.BobOtrProm = (Convert.ToDouble(TTurnoR2.BobOtrEsc) / Convert.ToInt32(TTurnoR2.BobOtrCant)).ToString("N1");
                TTurnoR2.BobOtrProG = ((Convert.ToDouble(TTurnoR2.BobOtrCant) / CantidadBob2) * 100).ToString("N2");
            }
            else
            {
                TTurnoR2.BobOtrProm = "0"; TTurnoR2.BobOtrProG = "0.00";
            }
            if (TTurnoR2.BobRotCant != "0")
            {
                TTurnoR2.BobRotProm = (Convert.ToDouble(TTurnoR2.BobRotEsc) / Convert.ToInt32(TTurnoR2.BobRotCant)).ToString("N1");
                TTurnoR2.BobRotProG = ((Convert.ToDouble(TTurnoR2.BobRotCant) / CantidadBob2) * 100).ToString("N2");
            }
            else
            {
                TTurnoR2.BobRotProm = "0"; TTurnoR2.BobRotProG = "0.00";
            }
            lista2.Add(TTurnoR2);

            List <Inf_Regional> lista3 = lista.Where(o => o.Turno == "Mañana" && o.Maquina.Substring(0, 3).ToUpper() == "WEB").ToList();
            int          CantidadBob3  = 0;
            Inf_Regional TTurno        = new Inf_Regional();

            foreach (Inf_Regional x in lista3)
            {
                CantidadBob3      = CantidadBob3 + (Convert.ToInt32(x.BobBueCant) + Convert.ToInt32(x.BobDetCant) + Convert.ToInt32(x.BobOtrCant) + Convert.ToInt32(x.BobRotCant));
                TTurno.Maquina    = "T. Turno";
                TTurno.BobBueCant = (Convert.ToInt32(x.BobBueCant) + Convert.ToInt32(TTurno.BobBueCant)).ToString(); TTurno.BobBueEsc = (Convert.ToDouble(x.BobBueEsc) + Convert.ToDouble(TTurno.BobBueEsc)).ToString();
                TTurno.BobDetCant = (Convert.ToInt32(x.BobDetCant) + Convert.ToInt32(TTurno.BobDetCant)).ToString(); TTurno.BobDetEsc = (Convert.ToDouble(x.BobDetEsc) + Convert.ToDouble(TTurno.BobDetEsc)).ToString();
                TTurno.BobOtrCant = (Convert.ToInt32(x.BobOtrCant) + Convert.ToInt32(TTurno.BobOtrCant)).ToString(); TTurno.BobOtrEsc = (Convert.ToDouble(x.BobOtrEsc) + Convert.ToDouble(TTurno.BobOtrEsc)).ToString();
                TTurno.BobRotCant = (Convert.ToInt32(x.BobRotCant) + Convert.ToInt32(TTurno.BobRotCant)).ToString(); TTurno.BobRotEsc = (Convert.ToDouble(x.BobRotEsc) + Convert.ToDouble(TTurno.BobRotEsc)).ToString();
            }
            if (TTurno.BobBueCant != "0")
            {
                TTurno.BobBueProm = (Convert.ToDouble(TTurno.BobBueEsc) / Convert.ToInt32(TTurno.BobBueCant)).ToString("N1");
                TTurno.BobBueProG = ((Convert.ToDouble(TTurno.BobBueCant) / CantidadBob3) * 100).ToString("N2");
            }
            else
            {
                TTurno.BobBueProm = "0"; TTurno.BobBueProG = "0.00";
            }
            if (TTurno.BobDetCant != "0")
            {
                TTurno.BobDetProm = (Convert.ToDouble(TTurno.BobDetEsc) / Convert.ToInt32(TTurno.BobDetCant)).ToString("N1");
                TTurno.BobDetProG = ((Convert.ToDouble(TTurno.BobDetCant) / CantidadBob3) * 100).ToString("N2");
            }
            else
            {
                TTurno.BobDetProm = "0"; TTurno.BobDetProG = "0.00";
            }
            if (TTurno.BobOtrCant != "0")
            {
                TTurno.BobOtrProm = (Convert.ToDouble(TTurno.BobOtrEsc) / Convert.ToInt32(TTurno.BobOtrCant)).ToString("N1");
                TTurno.BobOtrProG = ((Convert.ToDouble(TTurno.BobOtrCant) / CantidadBob3) * 100).ToString("N2");
            }
            else
            {
                TTurno.BobOtrProm = "0"; TTurno.BobOtrProG = "0.00";
            }
            if (TTurno.BobRotCant != "0")
            {
                TTurno.BobRotProm = (Convert.ToDouble(TTurno.BobRotEsc) / Convert.ToInt32(TTurno.BobRotCant)).ToString("N1");
                TTurno.BobRotProG = ((Convert.ToDouble(TTurno.BobRotCant) / CantidadBob3) * 100).ToString("N2");
            }
            else
            {
                TTurno.BobRotProm = "0"; TTurno.BobRotProG = "0.00";
            }
            lista3.Add(TTurno);
            List <Inf_Regional> lista4 = lista.Where(o => o.Maquina.Substring(0, 3).ToUpper() == "WEB" && o.Turno == "Tarde").ToList();
            int          CantidadBob4  = 0;
            Inf_Regional TTurno1       = new Inf_Regional();

            foreach (Inf_Regional x in lista4)
            {
                CantidadBob4       = CantidadBob4 + (Convert.ToInt32(x.BobBueCant) + Convert.ToInt32(x.BobDetCant) + Convert.ToInt32(x.BobOtrCant) + Convert.ToInt32(x.BobRotCant));
                TTurno1.Maquina    = "T. Turno";
                TTurno1.BobBueCant = (Convert.ToInt32(x.BobBueCant) + Convert.ToInt32(TTurno1.BobBueCant)).ToString(); TTurno1.BobBueEsc = (Convert.ToDouble(x.BobBueEsc) + Convert.ToDouble(TTurno1.BobBueEsc)).ToString();
                TTurno1.BobDetCant = (Convert.ToInt32(x.BobDetCant) + Convert.ToInt32(TTurno1.BobDetCant)).ToString(); TTurno1.BobDetEsc = (Convert.ToDouble(x.BobDetEsc) + Convert.ToDouble(TTurno1.BobDetEsc)).ToString();
                TTurno1.BobOtrCant = (Convert.ToInt32(x.BobOtrCant) + Convert.ToInt32(TTurno1.BobOtrCant)).ToString(); TTurno1.BobOtrEsc = (Convert.ToDouble(x.BobOtrEsc) + Convert.ToDouble(TTurno1.BobOtrEsc)).ToString();
                TTurno1.BobRotCant = (Convert.ToInt32(x.BobRotCant) + Convert.ToInt32(TTurno1.BobRotCant)).ToString(); TTurno1.BobRotEsc = (Convert.ToDouble(x.BobRotEsc) + Convert.ToDouble(TTurno1.BobRotEsc)).ToString();
            }
            if (TTurno1.BobBueCant != "0")
            {
                TTurno1.BobBueProm = (Convert.ToDouble(TTurno1.BobBueEsc) / Convert.ToInt32(TTurno1.BobBueCant)).ToString("N1");
                TTurno1.BobBueProG = ((Convert.ToDouble(TTurno1.BobBueCant) / CantidadBob4) * 100).ToString("N2");
            }
            else
            {
                TTurno1.BobBueProm = "0"; TTurno1.BobBueProG = "0.00";
            }
            if (TTurno1.BobDetCant != "0")
            {
                TTurno1.BobDetProm = (Convert.ToDouble(TTurno1.BobDetEsc) / Convert.ToInt32(TTurno1.BobDetCant)).ToString("N1");
                TTurno1.BobDetProG = ((Convert.ToDouble(TTurno1.BobDetCant) / CantidadBob4) * 100).ToString("N2");
            }
            else
            {
                TTurno1.BobDetProm = "0"; TTurno1.BobDetProG = "0.00";
            }
            if (TTurno1.BobOtrCant != "0")
            {
                TTurno1.BobOtrProm = (Convert.ToDouble(TTurno1.BobOtrEsc) / Convert.ToInt32(TTurno1.BobOtrCant)).ToString("N1");
                TTurno1.BobOtrProG = ((Convert.ToDouble(TTurno1.BobOtrCant) / CantidadBob4) * 100).ToString("N2");
            }
            else
            {
                TTurno1.BobOtrProm = "0"; TTurno1.BobOtrProG = "0.00";
            }
            if (TTurno1.BobRotCant != "0")
            {
                TTurno1.BobRotProm = (Convert.ToDouble(TTurno1.BobRotEsc) / Convert.ToInt32(TTurno1.BobRotCant)).ToString("N1");
                TTurno1.BobRotProG = ((Convert.ToDouble(TTurno1.BobRotCant) / CantidadBob4) * 100).ToString("N2");
            }
            else
            {
                TTurno1.BobRotProm = "0"; TTurno1.BobRotProG = "0.00";
            }
            lista4.Add(TTurno1);
            List <Inf_Regional> lista5 = lista.Where(o => o.Maquina.Substring(0, 3).ToUpper() == "WEB" && o.Turno == "Noche").ToList();
            int          CantidadBob5  = 0;
            Inf_Regional TTurno2       = new Inf_Regional();

            foreach (Inf_Regional x in lista5)
            {
                CantidadBob5       = CantidadBob5 + (Convert.ToInt32(x.BobBueCant) + Convert.ToInt32(x.BobDetCant) + Convert.ToInt32(x.BobOtrCant) + Convert.ToInt32(x.BobRotCant));
                TTurno2.Maquina    = "T. Turno";
                TTurno2.BobBueCant = (Convert.ToInt32(x.BobBueCant) + Convert.ToInt32(TTurno2.BobBueCant)).ToString(); TTurno2.BobBueEsc = (Convert.ToDouble(x.BobBueEsc) + Convert.ToDouble(TTurno2.BobBueEsc)).ToString();
                TTurno2.BobDetCant = (Convert.ToInt32(x.BobDetCant) + Convert.ToInt32(TTurno2.BobDetCant)).ToString(); TTurno2.BobDetEsc = (Convert.ToDouble(x.BobDetEsc) + Convert.ToDouble(TTurno2.BobDetEsc)).ToString();
                TTurno2.BobOtrCant = (Convert.ToInt32(x.BobOtrCant) + Convert.ToInt32(TTurno2.BobOtrCant)).ToString(); TTurno2.BobOtrEsc = (Convert.ToDouble(x.BobOtrEsc) + Convert.ToDouble(TTurno2.BobOtrEsc)).ToString();
                TTurno2.BobRotCant = (Convert.ToInt32(x.BobRotCant) + Convert.ToInt32(TTurno2.BobRotCant)).ToString(); TTurno2.BobRotEsc = (Convert.ToDouble(x.BobRotEsc) + Convert.ToDouble(TTurno2.BobRotEsc)).ToString();
            }
            if (TTurno2.BobBueCant != "0")
            {
                TTurno2.BobBueProm = (Convert.ToDouble(TTurno2.BobBueEsc) / Convert.ToInt32(TTurno2.BobBueCant)).ToString("N1");
                TTurno2.BobBueProG = ((Convert.ToDouble(TTurno2.BobBueCant) / CantidadBob5) * 100).ToString("N2");
            }
            else
            {
                TTurno2.BobBueProm = "0"; TTurno2.BobBueProG = "0.00";
            }
            if (TTurno2.BobDetCant != "0")
            {
                TTurno2.BobDetProm = (Convert.ToDouble(TTurno2.BobDetEsc) / Convert.ToInt32(TTurno2.BobDetCant)).ToString("N1");
                TTurno2.BobDetProG = ((Convert.ToDouble(TTurno2.BobDetCant) / CantidadBob5) * 100).ToString("N2");
            }
            else
            {
                TTurno2.BobDetProm = "0"; TTurno2.BobDetProG = "0.00";
            }
            if (TTurno2.BobOtrCant != "0")
            {
                TTurno2.BobOtrProm = (Convert.ToDouble(TTurno2.BobOtrEsc) / Convert.ToInt32(TTurno2.BobOtrCant)).ToString("N1");
                TTurno2.BobOtrProG = ((Convert.ToDouble(TTurno2.BobOtrCant) / CantidadBob5) * 100).ToString("N2");
            }
            else
            {
                TTurno2.BobOtrProm = "0"; TTurno2.BobOtrProG = "0.00";
            }
            if (TTurno2.BobRotCant != "0")
            {
                TTurno2.BobRotProm = (Convert.ToDouble(TTurno2.BobRotEsc) / Convert.ToInt32(TTurno2.BobRotCant)).ToString("N1");
                TTurno2.BobRotProG = ((Convert.ToDouble(TTurno2.BobRotCant) / CantidadBob5) * 100).ToString("N2");
            }
            else
            {
                TTurno2.BobRotProm = "0"; TTurno2.BobRotProG = "0.00";
            }
            lista5.Add(TTurno2);
            List <Inf_Regional> lista6 = lista.Where(o => o.Maquina == "General").ToList();

            GridView MaquinasMR = new GridView();

            MaquinasMR.DataSource = lista1;
            MaquinasMR.DataBind();
            MaquinasMR.HeaderStyle.BackColor = System.Drawing.Color.Blue;
            MaquinasMR.HeaderStyle.ForeColor = System.Drawing.Color.White;

            GridView MaquinasTR = new GridView();

            MaquinasTR.DataSource = lista2;
            MaquinasTR.DataBind();
            MaquinasTR.HeaderStyle.BackColor = System.Drawing.Color.Blue;
            MaquinasTR.HeaderStyle.ForeColor = System.Drawing.Color.White;

            GridView MaquinasMW = new GridView();

            MaquinasMW.DataSource = lista3;
            MaquinasMW.DataBind();
            MaquinasMW.HeaderStyle.BackColor = System.Drawing.Color.Blue;
            MaquinasMW.HeaderStyle.ForeColor = System.Drawing.Color.White;

            GridView MaquinaTW = new GridView();

            MaquinaTW.DataSource = lista4;
            MaquinaTW.DataBind();
            MaquinaTW.HeaderStyle.BackColor = System.Drawing.Color.Blue;
            MaquinaTW.HeaderStyle.ForeColor = System.Drawing.Color.White;

            GridView MaquinaNW = new GridView();

            MaquinaNW.DataSource = lista5;
            MaquinaNW.DataBind();
            MaquinaNW.HeaderStyle.BackColor = System.Drawing.Color.Blue;
            MaquinaNW.HeaderStyle.ForeColor = System.Drawing.Color.White;

            MaquinasMR.HeaderRow.Cells[1].Text     = "Bob.";
            MaquinasMR.HeaderRow.Cells[2].Text     = "Peso";
            MaquinasMR.HeaderRow.Cells[3].Text     = "P. Prom";
            MaquinasMR.HeaderRow.Cells[4].Text     = "%";
            MaquinasMR.HeaderRow.Cells[5].Text     = "Bob.";
            MaquinasMR.HeaderRow.Cells[6].Text     = "Peso";
            MaquinasMR.HeaderRow.Cells[7].Text     = "P. Prom";
            MaquinasMR.HeaderRow.Cells[8].Text     = "%";
            MaquinasMR.HeaderRow.Cells[9].Text     = "Bob.";
            MaquinasMR.HeaderRow.Cells[10].Text    = "Peso";
            MaquinasMR.HeaderRow.Cells[11].Text    = "P. Prom";
            MaquinasMR.HeaderRow.Cells[12].Text    = "%";
            MaquinasMR.HeaderRow.Cells[13].Text    = "Bob.";
            MaquinasMR.HeaderRow.Cells[14].Text    = "Peso";
            MaquinasMR.HeaderRow.Cells[15].Text    = "P. Prom";
            MaquinasMR.HeaderRow.Cells[16].Text    = "%";
            MaquinasMR.HeaderRow.Cells[17].Visible = false;

            MaquinasTR.HeaderRow.Cells[1].Text     = "Bob.";
            MaquinasTR.HeaderRow.Cells[2].Text     = "Peso";
            MaquinasTR.HeaderRow.Cells[3].Text     = "P. Prom";
            MaquinasTR.HeaderRow.Cells[4].Text     = "%";
            MaquinasTR.HeaderRow.Cells[5].Text     = "Bob.";
            MaquinasTR.HeaderRow.Cells[6].Text     = "Peso";
            MaquinasTR.HeaderRow.Cells[7].Text     = "P. Prom";
            MaquinasTR.HeaderRow.Cells[8].Text     = "%";
            MaquinasTR.HeaderRow.Cells[9].Text     = "Bob.";
            MaquinasTR.HeaderRow.Cells[10].Text    = "Peso";
            MaquinasTR.HeaderRow.Cells[11].Text    = "P. Prom";
            MaquinasTR.HeaderRow.Cells[12].Text    = "%";
            MaquinasTR.HeaderRow.Cells[13].Text    = "Bob.";
            MaquinasTR.HeaderRow.Cells[14].Text    = "Peso";
            MaquinasTR.HeaderRow.Cells[15].Text    = "P. Prom";
            MaquinasTR.HeaderRow.Cells[16].Text    = "%";
            MaquinasTR.HeaderRow.Cells[17].Visible = false;

            MaquinasMW.HeaderRow.Cells[1].Text     = "Bob.";
            MaquinasMW.HeaderRow.Cells[2].Text     = "Peso";
            MaquinasMW.HeaderRow.Cells[3].Text     = "P. Prom";
            MaquinasMW.HeaderRow.Cells[4].Text     = "%";
            MaquinasMW.HeaderRow.Cells[5].Text     = "Bob.";
            MaquinasMW.HeaderRow.Cells[6].Text     = "Peso";
            MaquinasMW.HeaderRow.Cells[7].Text     = "P. Prom";
            MaquinasMW.HeaderRow.Cells[8].Text     = "%";
            MaquinasMW.HeaderRow.Cells[9].Text     = "Bob.";
            MaquinasMW.HeaderRow.Cells[10].Text    = "Peso";
            MaquinasMW.HeaderRow.Cells[11].Text    = "P. Prom";
            MaquinasMW.HeaderRow.Cells[12].Text    = "%";
            MaquinasMW.HeaderRow.Cells[13].Text    = "Bob.";
            MaquinasMW.HeaderRow.Cells[14].Text    = "Peso";
            MaquinasMW.HeaderRow.Cells[15].Text    = "P. Prom";
            MaquinasMW.HeaderRow.Cells[16].Text    = "%";
            MaquinasMW.HeaderRow.Cells[17].Visible = false;

            MaquinaTW.HeaderRow.Cells[1].Text     = "Bob.";
            MaquinaTW.HeaderRow.Cells[2].Text     = "Peso";
            MaquinaTW.HeaderRow.Cells[3].Text     = "P. Prom";
            MaquinaTW.HeaderRow.Cells[4].Text     = "%";
            MaquinaTW.HeaderRow.Cells[5].Text     = "Bob.";
            MaquinaTW.HeaderRow.Cells[6].Text     = "Peso";
            MaquinaTW.HeaderRow.Cells[7].Text     = "P. Prom";
            MaquinaTW.HeaderRow.Cells[8].Text     = "%";
            MaquinaTW.HeaderRow.Cells[9].Text     = "Bob.";
            MaquinaTW.HeaderRow.Cells[10].Text    = "Peso";
            MaquinaTW.HeaderRow.Cells[11].Text    = "P. Prom";
            MaquinaTW.HeaderRow.Cells[12].Text    = "%";
            MaquinaTW.HeaderRow.Cells[13].Text    = "Bob.";
            MaquinaTW.HeaderRow.Cells[14].Text    = "Peso";
            MaquinaTW.HeaderRow.Cells[15].Text    = "P. Prom";
            MaquinaTW.HeaderRow.Cells[16].Text    = "%";
            MaquinaTW.HeaderRow.Cells[17].Visible = false;

            MaquinaNW.HeaderRow.Cells[1].Text     = "Bob.";
            MaquinaNW.HeaderRow.Cells[2].Text     = "Peso";
            MaquinaNW.HeaderRow.Cells[3].Text     = "P. Prom";
            MaquinaNW.HeaderRow.Cells[4].Text     = "%";
            MaquinaNW.HeaderRow.Cells[5].Text     = "Bob.";
            MaquinaNW.HeaderRow.Cells[6].Text     = "Peso";
            MaquinaNW.HeaderRow.Cells[7].Text     = "P. Prom";
            MaquinaNW.HeaderRow.Cells[8].Text     = "%";
            MaquinaNW.HeaderRow.Cells[9].Text     = "Bob.";
            MaquinaNW.HeaderRow.Cells[10].Text    = "Peso";
            MaquinaNW.HeaderRow.Cells[11].Text    = "P. Prom";
            MaquinaNW.HeaderRow.Cells[12].Text    = "%";
            MaquinaNW.HeaderRow.Cells[13].Text    = "Bob.";
            MaquinaNW.HeaderRow.Cells[14].Text    = "Peso";
            MaquinaNW.HeaderRow.Cells[15].Text    = "P. Prom";
            MaquinaNW.HeaderRow.Cells[16].Text    = "%";
            MaquinaNW.HeaderRow.Cells[17].Visible = false;

            for (int contador = 0; contador < MaquinasMR.Rows.Count; contador++)
            {
                GridViewRow row = MaquinasMR.Rows[contador];
                row.Cells[1].Style.Add("text-align", "right");
                row.Cells[2].Style.Add("text-align", "right");
                row.Cells[3].Style.Add("text-align", "right");
                row.Cells[4].Style.Add("text-align", "right");
                row.Cells[5].Style.Add("text-align", "right");
                row.Cells[6].Style.Add("text-align", "right");
                row.Cells[7].Style.Add("text-align", "right");
                row.Cells[8].Style.Add("text-align", "right");
                row.Cells[9].Style.Add("text-align", "right");
                row.Cells[10].Style.Add("text-align", "right");
                row.Cells[11].Style.Add("text-align", "right");
                row.Cells[12].Style.Add("text-align", "right");
                row.Cells[13].Style.Add("text-align", "right");
                row.Cells[14].Style.Add("text-align", "right");
                row.Cells[15].Style.Add("text-align", "right");
                row.Cells[16].Style.Add("text-align", "right");
                row.Cells[17].Visible = false;
            }
            for (int contador = 0; contador < MaquinasTR.Rows.Count; contador++)
            {
                GridViewRow row = MaquinasTR.Rows[contador];
                row.Cells[1].Style.Add("text-align", "right");
                row.Cells[2].Style.Add("text-align", "right");
                row.Cells[3].Style.Add("text-align", "right");
                row.Cells[4].Style.Add("text-align", "right");
                row.Cells[5].Style.Add("text-align", "right");
                row.Cells[6].Style.Add("text-align", "right");
                row.Cells[7].Style.Add("text-align", "right");
                row.Cells[8].Style.Add("text-align", "right");
                row.Cells[9].Style.Add("text-align", "right");
                row.Cells[10].Style.Add("text-align", "right");
                row.Cells[11].Style.Add("text-align", "right");
                row.Cells[12].Style.Add("text-align", "right");
                row.Cells[13].Style.Add("text-align", "right");
                row.Cells[14].Style.Add("text-align", "right");
                row.Cells[15].Style.Add("text-align", "right");
                row.Cells[16].Style.Add("text-align", "right");
                row.Cells[17].Visible = false;
            }
            for (int contador = 0; contador < MaquinasMW.Rows.Count; contador++)
            {
                GridViewRow row = MaquinasMW.Rows[contador];
                row.Cells[1].Style.Add("text-align", "right");
                row.Cells[2].Style.Add("text-align", "right");
                row.Cells[3].Style.Add("text-align", "right");
                row.Cells[4].Style.Add("text-align", "right");
                row.Cells[5].Style.Add("text-align", "right");
                row.Cells[6].Style.Add("text-align", "right");
                row.Cells[7].Style.Add("text-align", "right");
                row.Cells[8].Style.Add("text-align", "right");
                row.Cells[9].Style.Add("text-align", "right");
                row.Cells[10].Style.Add("text-align", "right");
                row.Cells[11].Style.Add("text-align", "right");
                row.Cells[12].Style.Add("text-align", "right");
                row.Cells[13].Style.Add("text-align", "right");
                row.Cells[14].Style.Add("text-align", "right");
                row.Cells[15].Style.Add("text-align", "right");
                row.Cells[16].Style.Add("text-align", "right");
                row.Cells[17].Visible = false;
            }
            for (int contador = 0; contador < MaquinaTW.Rows.Count; contador++)
            {
                GridViewRow row = MaquinaTW.Rows[contador];
                row.Cells[1].Style.Add("text-align", "right");
                row.Cells[2].Style.Add("text-align", "right");
                row.Cells[3].Style.Add("text-align", "right");
                row.Cells[4].Style.Add("text-align", "right");
                row.Cells[5].Style.Add("text-align", "right");
                row.Cells[6].Style.Add("text-align", "right");
                row.Cells[7].Style.Add("text-align", "right");
                row.Cells[8].Style.Add("text-align", "right");
                row.Cells[9].Style.Add("text-align", "right");
                row.Cells[10].Style.Add("text-align", "right");
                row.Cells[11].Style.Add("text-align", "right");
                row.Cells[12].Style.Add("text-align", "right");
                row.Cells[13].Style.Add("text-align", "right");
                row.Cells[14].Style.Add("text-align", "right");
                row.Cells[15].Style.Add("text-align", "right");
                row.Cells[16].Style.Add("text-align", "right");
                row.Cells[17].Visible = false;
            }
            for (int contador = 0; contador < MaquinaNW.Rows.Count; contador++)
            {
                GridViewRow row = MaquinaNW.Rows[contador];
                row.Cells[1].Style.Add("text-align", "right");
                row.Cells[2].Style.Add("text-align", "right");
                row.Cells[3].Style.Add("text-align", "right");
                row.Cells[4].Style.Add("text-align", "right");
                row.Cells[5].Style.Add("text-align", "right");
                row.Cells[6].Style.Add("text-align", "right");
                row.Cells[7].Style.Add("text-align", "right");
                row.Cells[8].Style.Add("text-align", "right");
                row.Cells[9].Style.Add("text-align", "right");
                row.Cells[10].Style.Add("text-align", "right");
                row.Cells[11].Style.Add("text-align", "right");
                row.Cells[12].Style.Add("text-align", "right");
                row.Cells[13].Style.Add("text-align", "right");
                row.Cells[14].Style.Add("text-align", "right");
                row.Cells[15].Style.Add("text-align", "right");
                row.Cells[16].Style.Add("text-align", "right");
                row.Cells[17].Visible = false;
            }

            string Titulo = "<div align='center'>Reporte de Desponche por Turno <br/>Rango de Fechas: Desde: " + txtFechaInicio.Text + " Hasta " + txtFechaTermino.Text + " </div><br />";

            la.Text = Titulo;
            form.Controls.Add(la);

            Label MaquinasM = new Label();

            MaquinasM.Text = "<table><tr><td>2 Turnos</td><td>12 Horas</td></tr></table><table style='width: 100%;'>" +
                             "<tr><td style='border:1px solid black;'>Turno Mañana</td>" +
                             "<td style='border:1px solid black;' colspan='4' align='center'>Bobina Buena</td>" +
                             "<td style='border:1px solid black;' colspan='4' align='center'>Problema Rotativa</td>" +
                             "<td style='border:1px solid black;' colspan='4' align='center'>Deposito</td>" +
                             "<td style='border:1px solid black;' colspan='4' align='center'>Otros Daños</td></tr></table>";
            form.Controls.Add(MaquinasM);
            form.Controls.Add(MaquinasMR);

            Label MaquinaT = new Label();

            MaquinaT.Text = "<br/><table style='width: 100%;'>" +
                            "<tr><td style='border:1px solid black;'>Turno Tarde</td>" +
                            "<td style='border:1px solid black;' colspan='4' align='center'>Bobina Buena</td>" +
                            "<td style='border:1px solid black;' colspan='4' align='center'>Problema Rotativa</td>" +
                            "<td style='border:1px solid black;' colspan='4' align='center'>Deposito</td>" +
                            "<td style='border:1px solid black;' colspan='4' align='center'>Otros Daños</td></tr></table>";
            form.Controls.Add(MaquinaT);
            form.Controls.Add(MaquinasTR);

            Label TaTotLitho = new Label();

            TaTotLitho.Text = "<br/><table><tr><td>3 Turnos</td><td>8 Horas</td></tr></table><table style='width: 100%;'>" +
                              "<tr><td style='border:1px solid black;'>Turno Mañana</td>" +
                              "<td style='border:1px solid black;' colspan='4' align='center'>Bobina Buena</td>" +
                              "<td style='border:1px solid black;' colspan='4' align='center'>Problema Rotativa</td>" +
                              "<td style='border:1px solid black;' colspan='4' align='center'>Deposito</td>" +
                              "<td style='border:1px solid black;' colspan='4' align='center'>Otros Daños</td></tr></table>";
            form.Controls.Add(TaTotLitho);
            form.Controls.Add(MaquinasMW);

            Label TaTotM600 = new Label();

            TaTotM600.Text = "<br/><table style='width: 100%;'>" +
                             "<tr><td style='border:1px solid black;'>Turno Tarde</td>" +
                             "<td style='border:1px solid black;' colspan='4' align='center'>Bobina Buena</td>" +
                             "<td style='border:1px solid black;' colspan='4' align='center'>Problema Rotativa</td>" +
                             "<td style='border:1px solid black;' colspan='4' align='center'>Deposito</td>" +
                             "<td style='border:1px solid black;' colspan='4' align='center'>Otros Daños</td></tr></table>";
            form.Controls.Add(TaTotM600);
            form.Controls.Add(MaquinaTW);

            Label TaTotDimen = new Label();

            TaTotDimen.Text = "<br/><table style='width: 100%;'>" +
                              "<tr><td style='border:1px solid black;'>Turno Noche</td>" +
                              "<td style='border:1px solid black;' colspan='4' align='center'>Bobina Buena</td>" +
                              "<td style='border:1px solid black;' colspan='4' align='center'>Problema Rotativa</td>" +
                              "<td style='border:1px solid black;' colspan='4' align='center'>Deposito</td>" +
                              "<td style='border:1px solid black;' colspan='4' align='center'>Otros Daños</td></tr></table>";
            form.Controls.Add(TaTotDimen);
            form.Controls.Add(MaquinaNW);

            Label        TaTotWeb1 = new Label();
            Inf_Regional regional  = new Inf_Regional();

            foreach (Inf_Regional a in lista6)
            {
                regional = a;
            }
            TaTotWeb1.Text = "<br/><table style='width: 100%;'>" +
                             "<tr><td style='border:1px solid black;'>T. General</td>" +
                             "<td style='border:1px solid black;text-align:right;'>" + regional.BobBueCant + "</td><td style='border:1px solid black;text-align:right;'>" + regional.BobBueEsc + "</td><td style='border:1px solid black;text-align:right;'>" + regional.BobBueProm + "</td><td style='border:1px solid black;text-align:right;'>" + regional.BobBueProG + "</td>" +
                             "<td style='border:1px solid black;text-align:right;'>" + regional.BobRotCant + "</td><td style='border:1px solid black;text-align:right;'>" + regional.BobRotEsc + "</td><td style='border:1px solid black;text-align:right;'>" + regional.BobRotProm + "</td><td style='border:1px solid black;text-align:right;'>" + regional.BobRotProG + "</td>" +
                             "<td style='border:1px solid black;text-align:right;'>" + regional.BobDetCant + "</td><td style='border:1px solid black;text-align:right;'>" + regional.BobDetEsc + "</td><td style='border:1px solid black;text-align:right;'>" + regional.BobDetProm + "</td><td style='border:1px solid black;text-align:right;'>" + regional.BobDetProG + "</td>" +
                             "<td style='border:1px solid black;text-align:right;'>" + regional.BobOtrCant + "</td><td style='border:1px solid black;text-align:right;'>" + regional.BobOtrEsc + "</td><td style='border:1px solid black;text-align:right;'>" + regional.BobOtrProm + "</td><td style='border:1px solid black;text-align:right;'>" + regional.BobOtrProG + "</td></tr></table>";
            form.Controls.Add(TaTotWeb1);

            Label         TotalEscalpe = new Label();
            double        Total        = (Convert.ToDouble(regional.BobBueEsc) + Convert.ToDouble(regional.BobRotEsc) + Convert.ToDouble(regional.BobDetEsc) + Convert.ToDouble(regional.BobOtrEsc)) * 100;
            double        Total2       = Total / PesoTotalOrig;
            string        detalle      = "";
            List <Bobina> listadet     = controlb.ListarPromEsc(f1, f2);

            foreach (Bobina b in listadet)
            {
                detalle = detalle + "<tr><td colspan ='2'></td><td colspan ='2' style='border:1px solid black;'>Resumen</td><td colspan ='2' style='border:1px solid black;'>Con Proyectos</td><td colspan ='2' style='border:1px solid black;text-align:right;'>" + b.Lote.Replace(".", ",") + "</td><td style='border:1px solid black;text-align:right;'>" + b.Porc_Buenas + "%</td><td colspan ='2' style='border:1px solid black;'>Sin Proyectos</td><td style='border:1px solid black;text-align:right;'>" + b.Marca.Replace(".", ",") + "</td><td style='border:1px solid black;text-align:right;'>" + b.Porc_Malas + "%</td></tr>";
            }
            TotalEscalpe.Text = "<br/><table style='width: 100%;'><tr><td colspan ='2'></td><td colspan ='2' style='border:1px solid black;'>Total KG. Mes</td><td colspan ='2' style='border:1px solid black;text-align:right;'>" + PesoTotalOrig.ToString("N0").Replace(",", ".") + "</td>" +
                                "<td colspan ='2' style='border:1px solid black;'>Escarpe KG. Mes</td><td style='border:1px solid black;'>" + Convert.ToInt32(Total / 100).ToString("N0").Replace(",", ".") + "</td><td colspan ='2' style='border:1px solid black;'>% Escarpe/P.Bruto</td><td colspan ='2' style='border:1px solid black;text-align:right;'>" + Total2.ToString("N2") + "%</td></tr>" +
                                detalle + "<tr><td colspan ='2'></td><td colspan ='2' style='border:1px solid black;'>Prom. Escarpe Int</td><td colspan ='2' style='border:1px solid black;text-align:right;'>" + (((Convert.ToDouble(regional.BobBueEsc) + Convert.ToDouble(regional.BobRotEsc) + Convert.ToDouble(regional.BobDetEsc)) / PesoTotalOrig) * 100).ToString("N2") + "%</td><td colspan ='2' style='border:1px solid black;'>Total Escarpe Otr. Daños</td><td style='border:1px solid black;'>" + regional.BobOtrEsc + "</td></tr></table><br/>";
            form.Controls.Add(TotalEscalpe);

            pageToRender.Controls.Add(form);
            response.Clear();
            response.Buffer      = true;
            response.ContentType = "application/vnd.ms-excel";
            string fecha;

            if (txtFechaInicio.Text == "")
            {
                fecha = DateTime.Now.AddDays(-1).ToShortDateString();
            }
            else
            {
                fecha = txtFechaInicio.Text;
            }
            response.AddHeader("Content-Disposition", "attachment;filename=Reporte de Desponche " + fecha + ".xls");
            response.Charset         = "UTF-8";
            response.ContentEncoding = Encoding.Default;
            pageToRender.RenderControl(htw);
            response.Write(sw.ToString());
            response.End();


            //fin del excel
        }
        protected void ibExcel_Click(object sender, ImageClickEventArgs e)
        {
            int PesoTotalOrig = 0;
            int BobCProyect   = 0;
            int BobSProyect   = 0;
            //DateTime f1 = new DateTime();
            string f1 = "";
            string f2 = "";

            if (txtFechaInicio.Text != "")
            {
                string   fechaI = txtFechaInicio.Text;
                string[] str    = fechaI.Split('/');
                string   dia    = str[0];
                string   mes    = str[1];
                string   año    = str[2];
                año = año.Substring(0, 4);

                //string fechaInicio = mes + "/" + dia + "/" + año;

                f1 = año + "-" + mes + "-" + dia;//Convert.ToDateTime(fechaInicio);
                //txtCliente.Text = mes + "/" + dia + "/" + año;
                string   fechaT = txtFechaTermino.Text;
                string[] str2   = fechaT.Split('/');
                string   dia2   = str2[0];
                string   mes2   = str2[1];
                string   año2   = str2[2];
                año = año.Substring(0, 4);

                f2            = mes2 + "/" + dia2 + "/" + año2;
                PesoTotalOrig = controlbob.PesoOriginalTB(f1, f2);
            }
            else
            {
                f1 = DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd");
                f2 = DateTime.Now.ToString("yyyy-MM-dd");
            }
            List <Bobina_Excel> lista = controlbob.ListBobina_WarRom(f1, f2);

            List <Bobina_Excel> listaDimen = lista.Where(o => o.Maquina == "Dimensionadora").ToList();
            List <Bobina_Excel> listaM600  = lista.Where(o => o.Maquina == "M600").ToList();
            List <Bobina_Excel> listaLitho = lista.Where(o => o.Maquina == "Lithoman").ToList();
            List <Bobina_Excel> listaWeb1  = lista.Where(o => o.Maquina == "WEB 1").ToList();

            Bobina_Excel bob1 = new Bobina_Excel();
            Bobina_Excel bob2 = new Bobina_Excel();
            Bobina_Excel bob3 = new Bobina_Excel();
            Bobina_Excel bob4 = new Bobina_Excel();
            Bobina_Excel bob5 = new Bobina_Excel();

            GridView wControl = new GridView();

            wControl.DataSource = listaLitho;
            wControl.DataBind();
            wControl.HeaderStyle.BackColor = System.Drawing.Color.Blue;
            wControl.HeaderStyle.ForeColor = System.Drawing.Color.White;

            GridView GridM600 = new GridView();

            GridM600.DataSource = listaM600;
            GridM600.DataBind();
            GridM600.HeaderStyle.BackColor = System.Drawing.Color.Blue;
            GridM600.HeaderStyle.ForeColor = System.Drawing.Color.White;

            GridView GridDimen = new GridView();

            GridDimen.DataSource = listaDimen;
            GridDimen.DataBind();
            GridDimen.HeaderStyle.BackColor = System.Drawing.Color.Blue;
            GridDimen.HeaderStyle.ForeColor = System.Drawing.Color.White;

            GridView GridWeb1 = new GridView();

            GridWeb1.DataSource = listaWeb1;
            GridWeb1.DataBind();
            GridWeb1.HeaderStyle.BackColor = System.Drawing.Color.Blue;
            GridWeb1.HeaderStyle.ForeColor = System.Drawing.Color.White;
            //Inicio del Excel

            if (wControl.Rows.Count > 0)
            {
                wControl.HeaderRow.Cells[0].Text     = "Código Bobina";
                wControl.HeaderRow.Cells[1].Visible  = false;
                wControl.HeaderRow.Cells[2].Text     = "Nombre Papel";
                wControl.HeaderRow.Cells[3].Text     = "Gramaje";
                wControl.HeaderRow.Cells[4].Text     = "Peso Bobina";
                wControl.HeaderRow.Cells[5].Text     = "Estado Bobina";
                wControl.HeaderRow.Cells[6].Text     = "Origen Daño";
                wControl.HeaderRow.Cells[7].Text     = "Causa Daño";
                wControl.HeaderRow.Cells[8].Text     = "Kilos Escarpe";
                wControl.HeaderRow.Cells[9].Text     = "% Perdida";
                wControl.HeaderRow.Cells[10].Visible = false;
                wControl.HeaderRow.Cells[11].Visible = false;
                wControl.HeaderRow.Cells[12].Visible = false;
                wControl.HeaderRow.Cells[13].Visible = false;
                wControl.HeaderRow.Cells[14].Visible = false;
                wControl.HeaderRow.Cells[15].Visible = false;
                wControl.HeaderRow.Cells[16].Visible = false;
                wControl.HeaderRow.Cells[17].Visible = false;
                wControl.HeaderRow.Cells[18].Visible = false;
            }

            if (GridM600.Rows.Count > 0)
            {
                GridM600.HeaderRow.Cells[0].Text     = "Código Bobina";
                GridM600.HeaderRow.Cells[1].Visible  = false;
                GridM600.HeaderRow.Cells[2].Text     = "Nombre Papel";
                GridM600.HeaderRow.Cells[3].Text     = "Gramaje";
                GridM600.HeaderRow.Cells[4].Text     = "Peso Bobina";
                GridM600.HeaderRow.Cells[5].Text     = "Estado Bobina";
                GridM600.HeaderRow.Cells[6].Text     = "Origen Daño";
                GridM600.HeaderRow.Cells[7].Text     = "Causa Daño";
                GridM600.HeaderRow.Cells[8].Text     = "Kilos Escarpe";
                GridM600.HeaderRow.Cells[9].Text     = "% Perdida";
                GridM600.HeaderRow.Cells[10].Visible = false;
                GridM600.HeaderRow.Cells[11].Visible = false;
                GridM600.HeaderRow.Cells[12].Visible = false;
                GridM600.HeaderRow.Cells[13].Visible = false;
                GridM600.HeaderRow.Cells[14].Visible = false;
                GridM600.HeaderRow.Cells[15].Visible = false;
                GridM600.HeaderRow.Cells[16].Visible = false;
                GridM600.HeaderRow.Cells[17].Visible = false;
                GridM600.HeaderRow.Cells[18].Visible = false;
            }

            if (GridDimen.Rows.Count > 0)
            {
                GridDimen.HeaderRow.Cells[0].Text     = "Código Bobina";
                GridDimen.HeaderRow.Cells[1].Visible  = false;
                GridDimen.HeaderRow.Cells[2].Text     = "Nombre Papel";
                GridDimen.HeaderRow.Cells[3].Text     = "Gramaje";
                GridDimen.HeaderRow.Cells[4].Text     = "Peso Bobina";
                GridDimen.HeaderRow.Cells[5].Text     = "Estado Bobina";
                GridDimen.HeaderRow.Cells[6].Text     = "Origen Daño";
                GridDimen.HeaderRow.Cells[7].Text     = "Causa Daño";
                GridDimen.HeaderRow.Cells[8].Text     = "Kilos Escarpe";
                GridDimen.HeaderRow.Cells[9].Text     = "% Perdida";
                GridDimen.HeaderRow.Cells[10].Visible = false;
                GridDimen.HeaderRow.Cells[11].Visible = false;
                GridDimen.HeaderRow.Cells[12].Visible = false;
                GridDimen.HeaderRow.Cells[13].Visible = false;
                GridDimen.HeaderRow.Cells[14].Visible = false;
                GridDimen.HeaderRow.Cells[15].Visible = false;
                GridDimen.HeaderRow.Cells[16].Visible = false;
                GridDimen.HeaderRow.Cells[17].Visible = false;
                GridDimen.HeaderRow.Cells[18].Visible = false;
            }

            if (GridWeb1.Rows.Count > 0)
            {
                GridWeb1.HeaderRow.Cells[0].Text     = "Código Bobina";
                GridWeb1.HeaderRow.Cells[1].Visible  = false;
                GridWeb1.HeaderRow.Cells[2].Text     = "Nombre Papel";
                GridWeb1.HeaderRow.Cells[3].Text     = "Gramaje";
                GridWeb1.HeaderRow.Cells[4].Text     = "Peso Bobina";
                GridWeb1.HeaderRow.Cells[5].Text     = "Estado Bobina";
                GridWeb1.HeaderRow.Cells[6].Text     = "Origen Daño";
                GridWeb1.HeaderRow.Cells[7].Text     = "Causa Daño";
                GridWeb1.HeaderRow.Cells[8].Text     = "Kilos Escarpe";
                GridWeb1.HeaderRow.Cells[9].Text     = "% Perdida";
                GridWeb1.HeaderRow.Cells[10].Visible = false;
                GridWeb1.HeaderRow.Cells[11].Visible = false;
                GridWeb1.HeaderRow.Cells[12].Visible = false;
                GridWeb1.HeaderRow.Cells[13].Visible = false;
                GridWeb1.HeaderRow.Cells[14].Visible = false;
                GridWeb1.HeaderRow.Cells[15].Visible = false;
                GridWeb1.HeaderRow.Cells[16].Visible = false;
                GridWeb1.HeaderRow.Cells[17].Visible = false;
                GridWeb1.HeaderRow.Cells[18].Visible = false;
            }

            int count = 0;

            for (int contador = 0; contador < wControl.Rows.Count; contador++)
            {
                GridViewRow row = wControl.Rows[contador];
                row.Cells[1].Visible  = false;
                row.Cells[10].Visible = false;
                row.Cells[11].Visible = false;
                row.Cells[12].Visible = false;
                row.Cells[13].Visible = false;
                row.Cells[14].Visible = false;
                row.Cells[15].Visible = false;
                row.Cells[16].Visible = false;
                row.Cells[17].Visible = false;
                row.Cells[18].Visible = false;
                bob1.BBuenas          = row.Cells[11].Text;
                bob1.BMalas           = row.Cells[12].Text;
                bob1.BMalas_QG        = row.Cells[10].Text;
                bob1.Maquina          = row.Cells[13].Text; //total de Peso
                bob1.NombreOT         = row.Cells[14].Text; //Total de escarpe
                bob1.CProyecto        = row.Cells[15].Text;
                bob1.SProyecto        = row.Cells[16].Text;
                bob1.ProCProyec       = row.Cells[17].Text;
                bob1.ProSProyec       = row.Cells[18].Text;

                double PromedioBuenas = ((Convert.ToDouble(bob1.BMalas) * 100) / Convert.ToDouble(bob1.BBuenas));
                PromedioBuenas = Math.Round(PromedioBuenas);
                bob1.OT        = PromedioBuenas.ToString("N0") + "%";

                double PromedioMalas = ((Convert.ToDouble(bob1.BMalas_QG) * 100) / Convert.ToDouble(bob1.BBuenas));
                PromedioMalas      = Math.Round(PromedioMalas);
                bob1.Peso_Original = PromedioMalas.ToString("N0") + "%";

                double PromedioEscarpe = ((Convert.ToDouble(bob1.NombreOT)) / Convert.ToDouble(bob1.BBuenas));
                bob1.Pesos_Conos = PromedioEscarpe.ToString("N0");

                double escarpe = ((Convert.ToDouble(bob1.NombreOT) * 100) / Convert.ToDouble(bob1.Maquina));
                bob1.Pesos_Envoltura = escarpe.ToString("N1") + "%";



                if (count == 0)
                {
                    if (bob5.BBuenas != null)
                    {
                        bob5.BBuenas   = (Convert.ToDouble(bob1.BBuenas.ToString()) + Convert.ToDouble(bob5.BBuenas.ToString())).ToString();
                        bob5.BMalas    = (Convert.ToDouble(bob1.BMalas.ToString()) + Convert.ToDouble(bob5.BMalas.ToString())).ToString();
                        bob5.BMalas_QG = (Convert.ToDouble(bob1.BMalas_QG.ToString()) + Convert.ToDouble(bob5.BMalas_QG.ToString())).ToString();
                        bob5.Maquina   = (Convert.ToDouble(bob1.Maquina.ToString()) + Convert.ToDouble(bob5.Maquina.ToString())).ToString();
                        bob5.NombreOT  = (Convert.ToDouble(bob1.NombreOT.ToString()) + Convert.ToDouble(bob5.NombreOT.ToString())).ToString();

                        count = count + 1;
                    }
                    else
                    {
                        bob5.BBuenas   = Convert.ToDouble(bob1.BBuenas.ToString()).ToString();
                        bob5.BMalas    = Convert.ToDouble(bob1.BMalas.ToString()).ToString();
                        bob5.BMalas_QG = Convert.ToDouble(bob1.BMalas_QG.ToString()).ToString();
                        bob5.Maquina   = Convert.ToDouble(bob1.Maquina.ToString()).ToString();
                        bob5.NombreOT  = Convert.ToDouble(bob1.NombreOT.ToString()).ToString();
                        BobCProyect    = Convert.ToInt32(bob1.CProyecto);
                        BobSProyect    = Convert.ToInt32(bob1.SProyecto);

                        bob5.ProCProyec = bob1.ProCProyec;
                        bob5.ProSProyec = bob1.ProSProyec;
                        count           = count + 1;
                    }
                }
                double PesoOriginal = Convert.ToDouble(row.Cells[4].Text);
                if (row.Cells[4].Text.Length > 3)
                {
                    string po2 = PesoOriginal.ToString("N0").Replace(",", ".");
                    row.Cells[4].Text = po2;
                }
                else
                {
                    string po2 = PesoOriginal.ToString("N0");
                    row.Cells[4].Text = po2;
                }
            }
            count = 0;
            for (int contador = 0; contador < GridM600.Rows.Count; contador++)
            {
                GridViewRow row = GridM600.Rows[contador];
                row.Cells[1].Visible  = false;
                row.Cells[10].Visible = false;
                row.Cells[11].Visible = false;
                row.Cells[12].Visible = false;
                row.Cells[13].Visible = false;
                row.Cells[14].Visible = false;
                row.Cells[15].Visible = false;
                row.Cells[16].Visible = false;
                row.Cells[17].Visible = false;
                row.Cells[18].Visible = false;
                bob2.BBuenas          = row.Cells[11].Text;
                bob2.BMalas           = row.Cells[12].Text;
                bob2.BMalas_QG        = row.Cells[10].Text;
                bob2.Maquina          = row.Cells[13].Text;
                bob2.NombreOT         = row.Cells[14].Text;

                double PromedioBuenas = ((Convert.ToDouble(bob2.BMalas) * 100) / Convert.ToDouble(bob2.BBuenas));
                PromedioBuenas = Math.Round(PromedioBuenas);
                bob2.OT        = PromedioBuenas.ToString("N0") + "%";

                double PromedioMalas = ((Convert.ToDouble(bob2.BMalas_QG) * 100) / Convert.ToDouble(bob2.BBuenas));
                PromedioMalas      = Math.Round(PromedioMalas);
                bob2.Peso_Original = PromedioMalas.ToString("N0") + "%";

                double PromedioEscarpe = ((Convert.ToDouble(bob2.NombreOT)) / Convert.ToDouble(bob2.BBuenas));
                bob2.Pesos_Conos = PromedioEscarpe.ToString("N0");

                double escarpe = ((Convert.ToDouble(bob2.NombreOT) * 100) / Convert.ToDouble(bob2.Maquina));
                bob2.Pesos_Envoltura = escarpe.ToString("N1") + "%";

                if (count == 0)
                {
                    if (bob5.BBuenas != null)
                    {
                        bob5.BBuenas   = (Convert.ToDouble(bob2.BBuenas.ToString()) + Convert.ToDouble(bob5.BBuenas.ToString())).ToString();
                        bob5.BMalas    = (Convert.ToDouble(bob2.BMalas.ToString()) + Convert.ToDouble(bob5.BMalas.ToString())).ToString();
                        bob5.BMalas_QG = (Convert.ToDouble(bob2.BMalas_QG.ToString()) + Convert.ToDouble(bob5.BMalas_QG.ToString())).ToString();
                        bob5.Maquina   = (Convert.ToDouble(bob2.Maquina.ToString()) + Convert.ToDouble(bob5.Maquina.ToString())).ToString();
                        bob5.NombreOT  = (Convert.ToDouble(bob2.NombreOT.ToString()) + Convert.ToDouble(bob5.NombreOT.ToString())).ToString();

                        count = count + 1;
                    }
                    else
                    {
                        bob5.BBuenas   = Convert.ToDouble(bob2.BBuenas.ToString()).ToString();
                        bob5.BMalas    = Convert.ToDouble(bob2.BMalas.ToString()).ToString();
                        bob5.BMalas_QG = Convert.ToDouble(bob2.BMalas_QG.ToString()).ToString();
                        bob5.Maquina   = Convert.ToDouble(bob2.Maquina.ToString()).ToString();
                        bob5.NombreOT  = Convert.ToDouble(bob2.NombreOT.ToString()).ToString();

                        count = count + 1;
                    }
                }

                double PesoOriginal = Convert.ToDouble(row.Cells[4].Text);
                if (row.Cells[4].Text.Length > 3)
                {
                    string po2 = PesoOriginal.ToString("N0").Replace(",", ".");
                    row.Cells[4].Text = po2;
                }
                else
                {
                    string po2 = PesoOriginal.ToString("N0");
                    row.Cells[4].Text = po2;
                }
            }
            count = 0;
            for (int contador = 0; contador < GridDimen.Rows.Count; contador++)
            {
                GridViewRow row = GridDimen.Rows[contador];
                row.Cells[1].Visible  = false;
                row.Cells[10].Visible = false;
                row.Cells[11].Visible = false;
                row.Cells[12].Visible = false;
                row.Cells[13].Visible = false;
                row.Cells[14].Visible = false;
                row.Cells[15].Visible = false;
                row.Cells[16].Visible = false;
                row.Cells[17].Visible = false;
                row.Cells[18].Visible = false;
                bob3.BBuenas          = row.Cells[11].Text;
                bob3.BMalas           = row.Cells[12].Text;
                bob3.BMalas_QG        = row.Cells[10].Text;
                bob3.Maquina          = row.Cells[13].Text;
                bob3.NombreOT         = row.Cells[14].Text;

                double PromedioBuenas = ((Convert.ToDouble(bob3.BMalas) * 100) / Convert.ToDouble(bob3.BBuenas));
                PromedioBuenas = Math.Round(PromedioBuenas);
                bob3.OT        = PromedioBuenas.ToString("N0") + "%";

                double PromedioMalas = ((Convert.ToDouble(bob3.BMalas_QG) * 100) / Convert.ToDouble(bob3.BBuenas));
                PromedioMalas      = Math.Round(PromedioMalas);
                bob3.Peso_Original = PromedioMalas.ToString("N0") + "%";

                double PromedioEscarpe = ((Convert.ToDouble(bob3.NombreOT)) / Convert.ToDouble(bob3.BBuenas));
                bob3.Pesos_Conos = PromedioEscarpe.ToString("N0");

                double escarpe = ((Convert.ToDouble(bob3.NombreOT) * 100) / Convert.ToDouble(bob3.Maquina));
                bob3.Pesos_Envoltura = escarpe.ToString("N1") + "%";

                if (count == 0)
                {
                    if (bob5.BBuenas != null)
                    {
                        bob5.BBuenas   = (Convert.ToDouble(bob3.BBuenas.ToString()) + Convert.ToDouble(bob5.BBuenas.ToString())).ToString();
                        bob5.BMalas    = (Convert.ToDouble(bob3.BMalas.ToString()) + Convert.ToDouble(bob5.BMalas.ToString())).ToString();
                        bob5.BMalas_QG = (Convert.ToDouble(bob3.BMalas_QG.ToString()) + Convert.ToDouble(bob5.BMalas_QG.ToString())).ToString();
                        bob5.Maquina   = (Convert.ToDouble(bob3.Maquina.ToString()) + Convert.ToDouble(bob5.Maquina.ToString())).ToString();
                        bob5.NombreOT  = (Convert.ToDouble(bob3.NombreOT.ToString()) + Convert.ToDouble(bob5.NombreOT.ToString())).ToString();

                        count = count + 1;
                    }
                    else
                    {
                        bob5.BBuenas   = Convert.ToDouble(bob3.BBuenas.ToString()).ToString();
                        bob5.BMalas    = Convert.ToDouble(bob3.BMalas.ToString()).ToString();
                        bob5.BMalas_QG = Convert.ToDouble(bob3.BMalas_QG.ToString()).ToString();
                        bob5.Maquina   = Convert.ToDouble(bob3.Maquina.ToString()).ToString();
                        bob5.NombreOT  = Convert.ToDouble(bob3.NombreOT.ToString()).ToString();

                        count = count + 1;
                    }
                }

                double PesoOriginal = Convert.ToDouble(row.Cells[4].Text);
                if (row.Cells[4].Text.Length > 3)
                {
                    string po2 = PesoOriginal.ToString("N0").Replace(",", ".");
                    row.Cells[4].Text = po2;
                }
                else
                {
                    string po2 = PesoOriginal.ToString("N0");
                    row.Cells[4].Text = po2;
                }
            }
            count = 0;
            for (int contador = 0; contador < GridWeb1.Rows.Count; contador++)
            {
                GridViewRow row = GridWeb1.Rows[contador];
                row.Cells[1].Visible  = false;
                row.Cells[10].Visible = false;
                row.Cells[11].Visible = false;
                row.Cells[12].Visible = false;
                row.Cells[13].Visible = false;
                row.Cells[14].Visible = false;
                row.Cells[15].Visible = false;
                row.Cells[16].Visible = false;
                row.Cells[17].Visible = false;
                row.Cells[18].Visible = false;
                bob4.BBuenas          = row.Cells[11].Text;
                bob4.BMalas           = row.Cells[12].Text;
                bob4.BMalas_QG        = row.Cells[10].Text;
                bob4.Maquina          = row.Cells[13].Text;
                bob4.NombreOT         = row.Cells[14].Text;

                double PromedioBuenas = ((Convert.ToDouble(bob4.BMalas) * 100) / Convert.ToDouble(bob4.BBuenas));
                PromedioBuenas = Math.Round(PromedioBuenas);
                bob4.OT        = PromedioBuenas.ToString("N0") + "%";

                double PromedioMalas = ((Convert.ToDouble(bob4.BMalas_QG) * 100) / Convert.ToDouble(bob4.BBuenas));
                PromedioMalas      = Math.Round(PromedioMalas);
                bob4.Peso_Original = PromedioMalas.ToString("N0") + "%";

                double PromedioEscarpe = ((Convert.ToDouble(bob4.NombreOT)) / Convert.ToDouble(bob4.BBuenas));
                bob4.Pesos_Conos = PromedioEscarpe.ToString("N0");

                double escarpe = ((Convert.ToDouble(bob4.NombreOT) * 100) / Convert.ToDouble(bob4.Maquina));
                bob4.Pesos_Envoltura = escarpe.ToString("N1") + "%";

                if (count == 0)
                {
                    if (bob5.BBuenas != null)
                    {
                        bob5.BBuenas   = (Convert.ToDouble(bob4.BBuenas.ToString()) + Convert.ToDouble(bob5.BBuenas.ToString())).ToString();
                        bob5.BMalas    = (Convert.ToDouble(bob4.BMalas.ToString()) + Convert.ToDouble(bob5.BMalas.ToString())).ToString();
                        bob5.BMalas_QG = (Convert.ToDouble(bob4.BMalas_QG.ToString()) + Convert.ToDouble(bob5.BMalas_QG.ToString())).ToString();
                        bob5.Maquina   = (Convert.ToDouble(bob4.Maquina.ToString()) + Convert.ToDouble(bob5.Maquina.ToString())).ToString();
                        bob5.NombreOT  = (Convert.ToDouble(bob4.NombreOT.ToString()) + Convert.ToDouble(bob5.NombreOT.ToString())).ToString();

                        count = count + 1;
                    }
                    else
                    {
                        bob5.BBuenas   = Convert.ToDouble(bob4.BBuenas.ToString()).ToString();
                        bob5.BMalas    = Convert.ToDouble(bob4.BMalas.ToString()).ToString();
                        bob5.BMalas_QG = Convert.ToDouble(bob4.BMalas_QG.ToString()).ToString();
                        bob5.Maquina   = Convert.ToDouble(bob4.Maquina.ToString()).ToString();
                        bob5.NombreOT  = Convert.ToDouble(bob4.NombreOT.ToString()).ToString();
                        count          = count + 1;
                    }
                }

                double PesoOriginal = Convert.ToDouble(row.Cells[4].Text);
                if (row.Cells[4].Text.Length > 3)
                {
                    string po2 = PesoOriginal.ToString("N0").Replace(",", ".");
                    row.Cells[4].Text = po2;
                }
                else
                {
                    string po2 = PesoOriginal.ToString("N0");
                    row.Cells[4].Text = po2;
                }
            }
            count = 0;
            HttpResponse   response     = Response;
            StringWriter   sw           = new StringWriter();
            HtmlTextWriter htw          = new HtmlTextWriter(sw);
            Page           pageToRender = new Page();
            HtmlForm       form         = new HtmlForm();
            Label          la           = new Label();
            string         FechaTitulo;

            if (txtFechaInicio.Text == "")
            {
                FechaTitulo = DateTime.Now.AddDays(-1).ToShortDateString();
            }
            else
            {
                FechaTitulo = txtFechaInicio.Text;
            }
            string Titulo = "<div align='center'>Reporte Desperdicio Papel <br/>Dia: " + txtFechaInicio.Text + " Desde:00:00 Hasta 23:59:59 </div><br />";

            la.Text = Titulo;
            form.Controls.Add(la);
            if (wControl.Rows.Count > 0)
            {
                Label Maquina1 = new Label();
                Maquina1.Text = "<div>Lithoman </div><br/>";
                form.Controls.Add(Maquina1);
                form.Controls.Add(wControl);
                Label TaTotLitho = new Label();
                TaTotLitho.Text = "<br/><div align='right'><table><tr>" +
                                  "<td colspan ='6'></td><td  style='border:1px solid black;' colspan ='2'>Total Bobinas Consumidas</td>" +
                                  "<td style='border:1px solid black;'>" + bob1.BBuenas.ToString() + "</div></td></tr><tr>" +
                                  "<td colspan ='6'></td><td style='border:1px solid black;' colspan ='2'>Total Bobinas Buenas</td>" +
                                  "<td style='border:1px solid black;'>" + bob1.BMalas.ToString() + "</td></tr><tr>" +
                                  "<td colspan ='6'></td><td style='border:1px solid black;' colspan ='2'>Total Bobinas Malas</td>" +
                                  "<td style='border:1px solid black;'>" + bob1.BMalas_QG.ToString() + "</td></tr><tr>" +
                                  "<td colspan ='6'></td><td style='border:1px solid black;' colspan ='2'>Total Peso Bobina</td>" +
                                  "<td style='border:1px solid black;'>" + bob1.Maquina.ToString() + "</td></tr><tr>" +
                                  "<td colspan ='6'></td><td style='border:1px solid black;' colspan ='2'>Total Escarpe Bobina</td>" +
                                  "<td style='border:1px solid black;'>" + bob1.NombreOT.ToString() + "</td></tr><tr>" +
                                  "<td colspan ='6'></td><td style='border:1px solid black;' colspan ='2'>Promedio Bobina Buenas</td>" +
                                  "<td style='border:1px solid black;'>" + bob1.OT.ToString() + "</td></tr><tr>" +
                                  "<td colspan ='6'></td><td style='border:1px solid black;' colspan ='2'>Promedio Bobina Malas</td>" +
                                  "<td style='border:1px solid black;'>" + bob1.Peso_Original.ToString() + "</td></tr><tr>" +
                                  "<td colspan ='6'></td><td style='border:1px solid black;' colspan ='2'>Promedio escalpe por bobina - kg</td>" +
                                  "<td style='border:1px solid black;'>" + bob1.Pesos_Conos.ToString() + "</td></tr><tr>" +
                                  "<td colspan ='6'></td><td style='border:1px solid black;' colspan ='2'>Promedio Escarpe</td>" +
                                  "<td style='border:1px solid black;'>" + bob1.Pesos_Envoltura.ToString() + "</td></tr></table></div>";
                form.Controls.Add(TaTotLitho);
            }

            if (GridM600.Rows.Count > 0)
            {
                Label Maquina2 = new Label();
                Maquina2.Text = "<br/><div align='left'>M600 </div><br/>";
                form.Controls.Add(Maquina2);
                form.Controls.Add(GridM600);
                Label TaTotM600 = new Label();
                TaTotM600.Text = "<br/><div align='right'><table><tr>" +
                                 "<td colspan ='6'></td><td  style='border:1px solid black;' colspan ='2'>Total Bobinas Consumidas</td>" +
                                 "<td style='border:1px solid black;'>" + bob2.BBuenas.ToString() + "</div></td></tr><tr>" +
                                 "<td colspan ='6'></td><td style='border:1px solid black;' colspan ='2'>Total Bobinas Buenas</td>" +
                                 "<td style='border:1px solid black;'>" + bob2.BMalas.ToString() + "</td></tr><tr>" +
                                 "<td colspan ='6'></td><td style='border:1px solid black;' colspan ='2'>Total Bobinas Malas</td>" +
                                 "<td style='border:1px solid black;'>" + bob2.BMalas_QG.ToString() + "</td></tr><tr>" +
                                 "<td colspan ='6'></td><td style='border:1px solid black;' colspan ='2'>Total Peso Bobina</td>" +
                                 "<td style='border:1px solid black;'>" + bob2.Maquina.ToString() + "</td></tr><tr>" +
                                 "<td colspan ='6'></td><td style='border:1px solid black;' colspan ='2'>Total Escarpe Bobina</td>" +
                                 "<td style='border:1px solid black;'>" + bob2.NombreOT.ToString() + "</td></tr><tr>" +
                                 "<td colspan ='6'></td><td style='border:1px solid black;' colspan ='2'>Promedio Bobina Buenas</td>" +
                                 "<td style='border:1px solid black;'>" + bob2.OT.ToString() + "</td></tr><tr>" +
                                 "<td colspan ='6'></td><td style='border:1px solid black;' colspan ='2'>Promedio Bobina Malas</td>" +
                                 "<td style='border:1px solid black;'>" + bob2.Peso_Original.ToString() + "</td></tr><tr>" +
                                 "<td colspan ='6'></td><td style='border:1px solid black;' colspan ='2'>Promedio escalpe por bobina - kg</td>" +
                                 "<td style='border:1px solid black;'>" + bob2.Pesos_Conos.ToString() + "</td></tr><tr>" +
                                 "<td colspan ='6'></td><td style='border:1px solid black;' colspan ='2'>Promedio Escarpe</td>" +
                                 "<td style='border:1px solid black;'>" + bob2.Pesos_Envoltura.ToString() + "</td></tr></table></div>";
                form.Controls.Add(TaTotM600);
            }

            if (GridDimen.Rows.Count > 0)
            {
                Label Maquina3 = new Label();
                Maquina3.Text = "<br/><div align='left'>Dimensionadora </div><br/>";
                form.Controls.Add(Maquina3);
                form.Controls.Add(GridDimen);
                Label TaTotDimen = new Label();
                TaTotDimen.Text = "<br/><div align='right'><table><tr>" +
                                  "<td colspan ='6'></td><td  style='border:1px solid black;' colspan ='2'>Total Bobinas Consumidas</td>" +
                                  "<td style='border:1px solid black;'>" + bob3.BBuenas.ToString() + "</div></td></tr><tr>" +
                                  "<td colspan ='6'></td><td style='border:1px solid black;' colspan ='2'>Total Bobinas Buenas</td>" +
                                  "<td style='border:1px solid black;'>" + bob3.BMalas.ToString() + "</td></tr><tr>" +
                                  "<td colspan ='6'></td><td style='border:1px solid black;' colspan ='2'>Total Bobinas Malas</td>" +
                                  "<td style='border:1px solid black;'>" + bob3.BMalas_QG.ToString() + "</td></tr><tr>" +
                                  "<td colspan ='6'></td><td style='border:1px solid black;' colspan ='2'>Total Peso Bobina</td>" +
                                  "<td style='border:1px solid black;'>" + bob3.Maquina.ToString() + "</td></tr><tr>" +
                                  "<td colspan ='6'></td><td style='border:1px solid black;' colspan ='2'>Total Escarpe Bobina</td>" +
                                  "<td style='border:1px solid black;'>" + bob3.NombreOT.ToString() + "</td></tr><tr>" +
                                  "<td colspan ='6'></td><td style='border:1px solid black;' colspan ='2'>Promedio Bobina Buenas</td>" +
                                  "<td style='border:1px solid black;'>" + bob3.OT.ToString() + "</td></tr><tr>" +
                                  "<td colspan ='6'></td><td style='border:1px solid black;' colspan ='2'>Promedio Bobina Malas</td>" +
                                  "<td style='border:1px solid black;'>" + bob3.Peso_Original.ToString() + "</td></tr><tr>" +
                                  "<td colspan ='6'></td><td style='border:1px solid black;' colspan ='2'>Promedio escalpe por bobina - kg</td>" +
                                  "<td style='border:1px solid black;'>" + bob3.Pesos_Conos.ToString() + "</td></tr><tr>" +
                                  "<td colspan ='6'></td><td style='border:1px solid black;' colspan ='2'>Promedio Escarpe</td>" +
                                  "<td style='border:1px solid black;'>" + bob3.Pesos_Envoltura.ToString() + "</td></tr></table></div>";
                form.Controls.Add(TaTotDimen);
            }

            if (GridWeb1.Rows.Count > 0)
            {
                Label Maquina4 = new Label();
                Maquina4.Text = "<br/><div align='left'>Web 1 </div><br/>";
                form.Controls.Add(Maquina4);
                form.Controls.Add(GridWeb1);
                Label TaTotWeb1 = new Label();
                TaTotWeb1.Text = "<br/><div align='right'><table><tr>" +
                                 "<td colspan ='6'></td><td  style='border:1px solid black;' colspan ='2'>Total Bobinas Consumidas</td>" +
                                 "<td style='border:1px solid black;'>" + bob4.BBuenas.ToString() + "</div></td></tr><tr>" +
                                 "<td colspan ='6'></td><td style='border:1px solid black;' colspan ='2'>Total Bobinas Buenas</td>" +
                                 "<td style='border:1px solid black;'>" + bob4.BMalas.ToString() + "</td></tr><tr>" +
                                 "<td colspan ='6'></td><td style='border:1px solid black;' colspan ='2'>Total Bobinas Malas</td>" +
                                 "<td style='border:1px solid black;'>" + bob4.BMalas_QG.ToString() + "</td></tr><tr>" +
                                 "<td colspan ='6'></td><td style='border:1px solid black;' colspan ='2'>Total Peso Bobina</td>" +
                                 "<td style='border:1px solid black;'>" + bob4.Maquina.ToString() + "</td></tr><tr>" +
                                 "<td colspan ='6'></td><td style='border:1px solid black;' colspan ='2'>Total Escarpe Bobina</td>" +
                                 "<td style='border:1px solid black;'>" + bob4.NombreOT.ToString() + "</td></tr><tr>" +
                                 "<td colspan ='6'></td><td style='border:1px solid black;' colspan ='2'>Promedio Bobina Buenas</td>" +
                                 "<td style='border:1px solid black;'>" + bob4.OT.ToString() + "</td></tr><tr>" +
                                 "<td colspan ='6'></td><td style='border:1px solid black;' colspan ='2'>Promedio Bobina Malas</td>" +
                                 "<td style='border:1px solid black;'>" + bob4.Peso_Original.ToString() + "</td></tr><tr>" +
                                 "<td colspan ='6'></td><td style='border:1px solid black;' colspan ='2'>Promedio escalpe por bobina - kg</td>" +
                                 "<td style='border:1px solid black;'>" + bob4.Pesos_Conos.ToString() + "</td></tr><tr>" +
                                 "<td colspan ='6'></td><td style='border:1px solid black;' colspan ='2'>Promedio Escarpe</td>" +
                                 "<td style='border:1px solid black;'>" + bob4.Pesos_Envoltura.ToString() + "</td></tr></table></div>";
                form.Controls.Add(TaTotWeb1);
            }
            if (bob5.BBuenas.ToString() != null)
            {
                double PromedioBuenas = ((Convert.ToDouble(bob5.BMalas) * 100) / Convert.ToDouble(bob5.BBuenas));
                PromedioBuenas = Math.Round(PromedioBuenas);
                bob5.OT        = PromedioBuenas.ToString("N0") + "%";

                double PromedioMalas = ((Convert.ToDouble(bob5.BMalas_QG) * 100) / Convert.ToDouble(bob5.BBuenas));
                PromedioMalas      = Math.Round(PromedioMalas);
                bob5.Peso_Original = PromedioMalas.ToString("N0") + "%";

                double PromedioEscarpe = ((Convert.ToDouble(bob5.NombreOT)) / Convert.ToDouble(bob5.BBuenas));
                bob5.Pesos_Conos = PromedioEscarpe.ToString("N0");

                double escarpe = ((Convert.ToDouble(bob5.NombreOT) * 100) / Convert.ToDouble(PesoTotalOrig));//bob5.Maquina));
                bob5.Pesos_Envoltura = escarpe.ToString("N1") + "%";


                Label TaTotGeneral = new Label();
                TaTotGeneral.Text = "<br/><div align='right'><table><tr>" +
                                    "<td colspan ='6'></td><td  style='border:1px solid black;' colspan ='3'>General</td>" +
                                    "</tr><tr>" +
                                    "<td colspan ='6'></td><td  style='border:1px solid black;' colspan ='2'>Total Bobinas Consumidas</td>" +
                                    "<td style='border:1px solid black;'>" + bob5.BBuenas.ToString() + "</div></td></tr><tr>" +
                                    "<td colspan ='6'></td><td style='border:1px solid black;' colspan ='2'>Total Bobinas Buenas</td>" +
                                    "<td style='border:1px solid black;'>" + bob5.BMalas.ToString() + "</td></tr><tr>" +
                                    "<td colspan ='6'></td><td style='border:1px solid black;' colspan ='2'>Total Bobinas Malas</td>" +
                                    "<td style='border:1px solid black;'>" + bob5.BMalas_QG.ToString() + "</td></tr><tr>" +
                                    "<td colspan ='6'></td><td style='border:1px solid black;' colspan ='2'>Total Peso Bobina</td>" +
                                    "<td style='border:1px solid black;'>" + PesoTotalOrig.ToString("N0").Replace(",", ".") + "</td></tr><tr>" +
                                    "<td colspan ='6'></td><td style='border:1px solid black;' colspan ='2'>Total Escarpe Bobina</td>" +
                                    "<td style='border:1px solid black;'>" + bob5.NombreOT.ToString() + "</td></tr><tr>" +
                                    "<td colspan ='6'></td><td style='border:1px solid black;' colspan ='2'>Promedio Bobina Buenas</td>" +
                                    "<td style='border:1px solid black;'>" + bob5.OT.ToString() + "</td></tr><tr>" +
                                    "<td colspan ='6'></td><td style='border:1px solid black;' colspan ='2'>Promedio Bobina Malas</td>" +
                                    "<td style='border:1px solid black;'>" + bob5.Peso_Original.ToString() + "</td></tr><tr>" +
                                    "<td colspan ='6'></td><td style='border:1px solid black;' colspan ='2'>Promedio escalpe por bobina - kg</td>" +
                                    "<td style='border:1px solid black;'>" + bob5.Pesos_Conos.ToString() + "</td></tr><tr>" +
                                    "<td colspan ='6'></td><td style='border:1px solid black;' colspan ='2'>Promedio Escarpe</td>" +
                                    "<td style='border:1px solid black;'>" + bob5.Pesos_Envoltura.ToString() + "</td></tr><tr>" +
                                    "<td colspan ='6'></td><td style='border:1px solid black;' colspan ='2'>Total Bobina Proyecto</td>" +
                                    "<td style='border:1px solid black;'>" + BobCProyect.ToString("N0").Replace(",", ".") + "</td></tr><tr>" +
                                    "<td colspan ='6'></td><td style='border:1px solid black;' colspan ='2'>Total Bobina Sin Proyecto</td>" +
                                    "<td style='border:1px solid black;'>" + BobSProyect.ToString("N0").Replace(",", ".") + "</td></tr><tr>" +
                                    "<td colspan ='6'></td><td style='border:1px solid black;' colspan ='2'>Total % Con Proyecto</td>" +
                                    "<td style='border:1px solid black;'>" + bob5.ProCProyec.ToString() + "</td></tr><tr>" +
                                    "<td colspan ='6'></td><td style='border:1px solid black;' colspan ='2'>Total % Sin Proyecto</td>" +
                                    "<td style='border:1px solid black;'>" + bob5.ProSProyec.ToString() + "</td></tr></table></div>";
                //"<td colspan ='6'></td><td style='border:1px solid black;' colspan ='2'>Peso Total Bobi</td>" +
                //"<td style='border:1px solid black;'>" + PesoTotalOrig.ToString("N0").Replace(",", ".") + "</td></tr></table></div>";
                form.Controls.Add(TaTotGeneral);
            }

            //Label TotalEscalpe = new Label();
            //TotalEscalpe.Text = "<br/><div align='center'>"+PesoTotalOrig.ToString("N0").Replace(",",".")+"</div><br/>";
            //form.Controls.Add(TotalEscalpe);
            pageToRender.Controls.Add(form);
            response.Clear();
            response.Buffer      = true;
            response.ContentType = "application/vnd.ms-excel";
            string fecha;

            if (txtFechaInicio.Text == "")
            {
                fecha = DateTime.Now.AddDays(-1).ToShortDateString();
            }
            else
            {
                fecha = txtFechaInicio.Text;
            }
            response.AddHeader("Content-Disposition", "attachment;filename=Reporte Desperdicio Papel" + fecha + ".xls");
            response.Charset         = "UTF-8";
            response.ContentEncoding = Encoding.Default;
            pageToRender.RenderControl(htw);
            response.Write(sw.ToString());
            response.End();


            //fin del excel
        }