public ActionResult DescargarExcel(string transacciones) { CorfidDataAcces _corfidDataAccess = new CorfidDataAcces(); BaseResponse <List <OperacionesHistoricas> > result = new BaseResponse <List <OperacionesHistoricas> >(); result = _corfidDataAccess.generarExcel(transacciones); if (result.success) { string plantilla = System.Configuration.ConfigurationManager.AppSettings["operacionesHistoricas"]; XSSFWorkbook hssfworkbook; string path = AppDomain.CurrentDomain.BaseDirectory + plantilla; using (FileStream file = new FileStream(path, FileMode.Open, FileAccess.Read)) { hssfworkbook = new XSSFWorkbook(file); } ISheet sheet1 = hssfworkbook.GetSheet("Reporte"); IRow row = sheet1.GetRow(7); int i = 7; //List<OperacionesHistoricas> operacionesHistoricas; foreach (OperacionesHistoricas item in result.data) { row = sheet1.GetRow(i); if (row == null) { row = sheet1.CreateRow(i); } this.SetCellValue(hssfworkbook, row, 1, item.fecha); this.SetCellValue(hssfworkbook, row, 2, item.idTransaccion); this.SetCellValue(hssfworkbook, row, 3, item.partnersAdjuntado); this.SetCellValue(hssfworkbook, row, 4, item.usuario); this.SetCellValue(hssfworkbook, row, 5, item.quiere == "V" ? "Compra" : "Venta"); //this.SetCellValue(hssfworkbook, row, 6, item.tipoMoneda); this.SetCellValue(hssfworkbook, row, 6, item.quiere == "V" ? item.monto.ToString(): item.montoRecibe.ToString()); //Monto en Dolares this.SetCellValue(hssfworkbook, row, 7, item.precioPactado); this.SetCellValue(hssfworkbook, row, 8, item.quiere == "V" ? item.montoRecibe.ToString() : item.monto.ToString()); //Monto en Soles this.SetCellValue(hssfworkbook, row, 9, item.estadoSubasta); i++; } MemoryStream stream = new MemoryStream(); hssfworkbook.Write(stream); return(File(stream.ToArray(), "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "operacionesHistoricas.xlsx")); } else { return(RedirectToAction("ListaOperacionesHistoricas")); } }
public IHttpActionResult operacionesConfirmadas(PageResultParam model) { CorfidDataAcces _operador = new CorfidDataAcces(); var resultado = _operador.getOperacionesHistoricas(model); return(Ok(resultado)); }