public ActionResult Company()
        {
            var companyReportViewModel = new CompanyReportViewModel
            {
                Company       = new Company(),
                CompaniesList = _companiesManagement.GetOrderedCompaniesList()
            };

            return(View(companyReportViewModel));
        }
        public ActionResult Company(CompanyReportViewModel reportViewModel)
        {
            var transactionsList = _transactionsManagement.GetTransactions(reportViewModel.Company,
                                                                           reportViewModel.BeginningDate,
                                                                           reportViewModel.EndingDate);

            var tList = ReportInfoFromList(transactionsList);

            using (var excelPackage = new ExcelPackage())
            {
                var worksheet = excelPackage.Workbook.Worksheets.Add("Primera Hoja");

                //Here we have to select one of the following options: Manual or Auto writting
                //With the auto option, we should create a new class to avoid the complex objects mapping problems
                //instead of using the simple Transaction Class

                //1. Manual

                worksheet.Cells["A1"].Value = CODIGO_FACTURA;
                worksheet.Cells["B1"].Value = MONTO;
                worksheet.Cells["C1"].Value = PUNTOS;
                worksheet.Cells["D1"].Value = CODIGO_SAR;
                worksheet.Cells["E1"].Value = NOMBRE_VENDEDOR;
                worksheet.Cells["F1"].Value = FECHA;
                //worksheet.Cells["G1"].Value = TIENDA;
                worksheet.Cells["G1"].Value = COMPANIA;

                /*
                 * int i = 2;
                 * foreach (var transaction in transactionsList)
                 * {
                 *  worksheet.Cells["A" + i].Value = transaction.Amount;
                 *  worksheet.Cells["B" + i].Value = transaction.Amount;
                 *  i++;
                 * }
                 */
                //2. Automatic

                if (tList != null && tList.Count() != 0)
                {
                    worksheet.Cells["A2"].LoadFromCollection(tList);
                }

                return(File(excelPackage.GetAsByteArray(), "application/vnd.ms-excel", "a_cool_name.xls"));
            }
        }
 public CompanyReportViewer(ReportViewer reportViewerControl, CompanyReportViewModel viewModel)
 {
     ReportViewer = reportViewerControl;
     ReportName   = "CompanyReport";
     ViewModel    = viewModel;
 }