Пример #1
0
        public ActionResult ObtenerReporteWIP()
        {
            FileContentResult robj;
            //string year = Convert.ToString(Session["year_reporte"]);
            List <OrdenesCompra> listaPedidos   = objPedido.ListaOrdenCompraWIP(1).ToList();
            List <OrdenesCompra> listaShipped   = objPedido.ListaOrdenCompraWIP(2).ToList();
            List <OrdenesCompra> listaCancelled = objPedido.ListaOrdenCompraWIP(3).ToList();


            int row = 1;

            using (XLWorkbook libro_trabajo = new XLWorkbook())
            {             //Regex.Replace(pedido, @"\s+", " ");
                var wp = libro_trabajo.Worksheets.Add("WIP");
                var ws = libro_trabajo.Worksheets.Add("SHIPPED");
                var wc = libro_trabajo.Worksheets.Add("CANCELLED");
                wp.TabColor = XLColor.Green;
                ws.TabColor = XLColor.Yellow;
                wc.TabColor = XLColor.Red;

                //CABECERAS TABLA
                var           headers = new List <String[]>();
                List <String> titulos = new List <string>
                {
                    "CUSTOMER",
                    "RETAILER",
                    "P.O. RECVD DATA",
                    "PO NO.",
                    "BRAND NAME",
                    "AMT PO",
                    "REG/BULK",
                    "BALANCE QTY",
                    "EXPECTED SHIP DATE",
                    "ORIGINAL CUST DUE DATE",
                    "DESIGN NAME",
                    "STYLE",
                    "MillPO",
                    "COLOR",
                    "GENDER",
                    "BLANKS RECEIVED",
                    "PARTIAL/COMPLETE BLANKS",
                    "ART RECEIVED",
                    "TRIM RECEIVED",
                    "PACK INST.RCVD",
                    "PRICE TICKET RECEIVED",
                    "UCC RECEIVED",
                    "COMMENTS UPDATE",
                    "COMMENTS"
                };
                headers.Add(titulos.ToArray());
                ws.Cell(row, 1).Value = headers;
                ws.Range(row, 1, row, 24).Style.Fill.BackgroundColor = XLColor.FromArgb(0, 0, 0);
                ws.Range(row, 1, row, 24).Style.Font.FontColor       = XLColor.FromArgb(255, 255, 255);
                wp.Cell(row, 1).Value = headers;
                wp.Range(row, 1, row, 24).Style.Fill.BackgroundColor = XLColor.FromArgb(0, 0, 0);
                wp.Range(row, 1, row, 24).Style.Font.FontColor       = XLColor.FromArgb(255, 255, 255);
                wc.Cell(row, 1).Value = headers;
                wc.Range(row, 1, row, 24).Style.Fill.BackgroundColor = XLColor.FromArgb(0, 0, 0);
                wc.Range(row, 1, row, 24).Style.Font.FontColor       = XLColor.FromArgb(255, 255, 255);
                wp.RangeUsed().SetAutoFilter().Column(1);
                ws.RangeUsed().SetAutoFilter().Column(1);
                wc.RangeUsed().SetAutoFilter().Column(1);
                row++;                 //AGREGAR DATOS LISTAS
                SheetWIP(listaPedidos, wp, row);
                SheetShipped(listaShipped, ws, row);
                SheetCancelled(listaCancelled, wc, row);

                wp.Rows().AdjustToContents();
                wp.Columns().AdjustToContents();
                ws.Rows().AdjustToContents();
                ws.Columns().AdjustToContents();
                wc.Rows().AdjustToContents();
                wc.Columns().AdjustToContents();
                //ws.Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
                /***********D*O*W*N*L*O*A*D*************************************************************************************************************************************************************************/

                /* HttpResponse httpResponse = System.Web.HttpContext.Current.Response;
                 * httpResponse.Clear();
                 * httpResponse.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
                 * httpResponse.AddHeader("content-disposition", "attachment;filename=\"WIP.xlsx\"");*/
                // Flush the workbook to the Response.OutputStream
                using (MemoryStream memoryStream = new MemoryStream())
                {
                    libro_trabajo.SaveAs(memoryStream);
                    var bytesdata = File(memoryStream.ToArray(), "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "WIP.xlsx");
                    robj = bytesdata;
                }

                // return File(httpResponse.OutputStream);
            }
            return(Json(robj, JsonRequestBehavior.AllowGet));
        }
Пример #2
0
 public List <OrdenesCompra> CatalagoWIP(List <OrdenesCompra> listaPedidos, int estadoTab)
 {
     listaPedidos = objPedido.ListaOrdenCompraWIP(estadoTab).ToList();
     return(listaPedidos);
 }