public static SessionParaExcel ObtenerObjetoExcel(string anio, string mes, string fechaInicio, string fechaFin, string CtaContId) { var ObjExcel = new SessionParaExcel() { Anio = anio, Mes = mes, FechaInicio = fechaInicio, FechaFin = fechaFin, CtaContId = CtaContId }; return(ObjExcel); }
public static bool TieneFiltrosActivos(SessionParaExcel FiltrosExcel) { bool Result = false; if (FiltrosExcel.Anio != "0" || FiltrosExcel.Mes != "0" || !string.IsNullOrWhiteSpace(FiltrosExcel.FechaInicio) && !string.IsNullOrWhiteSpace(FiltrosExcel.FechaFin)) { Result = true; } return(Result); }
//public static List<CatorceTerViewModel> GetCatorceTerDesdeVoucher(FacturaPoliContext db, ClientesContablesModel ObjCliente) //{ // IQueryable<VoucherModel> QueryIandE = db.DBVoucher.Where(x => x.) // return null; //} public static byte[] GetExcelCatorceTer(List <CatorceTerViewModel> lstCatorceTer, ClientesContablesModel objCliente, bool InformarMembrete, SessionParaExcel Fechas) { string RutaEsteExcel = ParseExtensions.Get_AppData_Path("14Ter.xlsx"); byte[] ExcelByteArray = null; using (XLWorkbook excelFile = new XLWorkbook(RutaEsteExcel)) { var workSheet = excelFile.Worksheet(1); if (InformarMembrete == true) { workSheet.Cell("A1").Value = objCliente.RazonSocial; workSheet.Cell("A2").Value = objCliente.RUTEmpresa; workSheet.Cell("A3").Value = objCliente.Giro; workSheet.Cell("A4").Value = objCliente.Direccion; workSheet.Cell("A5").Value = objCliente.Ciudad; workSheet.Cell("A6").Value = objCliente.Representante; workSheet.Cell("A7").Value = objCliente.RUTRepresentante; } else { workSheet.Cell("A1").Value = string.Empty; workSheet.Cell("A2").Value = string.Empty; workSheet.Cell("A3").Value = string.Empty; workSheet.Cell("A4").Value = string.Empty; workSheet.Cell("A5").Value = string.Empty; workSheet.Cell("A6").Value = string.Empty; workSheet.Cell("A7").Value = string.Empty; } if (string.IsNullOrWhiteSpace(Fechas.Mes) && string.IsNullOrWhiteSpace(Fechas.Anio)) { workSheet.Cell("F8").Value = "Informe 14 Ter"; } else if (!string.IsNullOrWhiteSpace(Fechas.Mes) && !string.IsNullOrWhiteSpace(Fechas.Anio)) { workSheet.Cell("F8").Value = "Informe 14 Ter" + " " + ParseExtensions.obtenerNombreMes(Convert.ToInt32(Fechas.Mes)) + " " + Fechas.Anio; } else if (!string.IsNullOrWhiteSpace(Fechas.Anio) && string.IsNullOrWhiteSpace(Fechas.Mes)) { workSheet.Cell("F8").Value = "Informe 14 Ter" + " " + Fechas.Anio; } workSheet.Column("B").Style.DateFormat.Format = "dd-MM-yyyy"; workSheet.Columns("G:H").Style.NumberFormat.Format = "#,##0 ;-#,##0"; workSheet.Columns("A", "K").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left; int NumeroFilaExcel = 13; int Correlativo = 1; foreach (var itemTer in lstCatorceTer) { if (itemTer.TotalIngreso > 0 || itemTer.TotalEgreso > 0) { workSheet.Cell(NumeroFilaExcel, "F").Value = "TOTAL:"; workSheet.Cell(NumeroFilaExcel, "G").Value = itemTer.TotalIngreso; workSheet.Cell(NumeroFilaExcel, "H").Value = itemTer.TotalEgreso; } else { workSheet.Cell(NumeroFilaExcel, "A").Value = Correlativo; workSheet.Cell(NumeroFilaExcel, "B").Value = itemTer.Fecha; if (itemTer.TipoDocumento != 0) { workSheet.Cell(NumeroFilaExcel, "C").Value = itemTer.TipoDocumento.ToString(); } else { workSheet.Cell(NumeroFilaExcel, "C").Value = "Otros"; } workSheet.Cell(NumeroFilaExcel, "D").Value = itemTer.Folio; workSheet.Cell(NumeroFilaExcel, "E").Value = itemTer.NombreReceptor; workSheet.Cell(NumeroFilaExcel, "F").Value = itemTer.RutReceptor; workSheet.Cell(NumeroFilaExcel, "G").Value = itemTer.Ingreso; workSheet.Cell(NumeroFilaExcel, "H").Value = itemTer.Egreso; workSheet.Cell(NumeroFilaExcel, "I").Value = itemTer.CuentaContable; } workSheet.Range("A" + NumeroFilaExcel + ":K" + NumeroFilaExcel).Rows ().Style.Border.OutsideBorder = XLBorderStyleValues.Thin; workSheet.Range("A" + NumeroFilaExcel + ":K" + NumeroFilaExcel).Rows ().Style.Border.InsideBorder = XLBorderStyleValues.Thin; Correlativo++; NumeroFilaExcel++; } ExcelByteArray = ParseExtensions.GetExcelStream(excelFile); } if (ExcelByteArray == null) { return(null); } else { return(ExcelByteArray); } }