private FileResult ExportPerformanceReport(vmAdmin_PerformanceReport report, vmAdmin_PerformanceFilter filter, string title, string filename)
        {
            int rowNumber = 0;

            NPOI.SS.UserModel.IRow row;

            //Create new Excel workbook
            var workbook = new HSSFWorkbook();

            //Create new Excel sheet
            var sheet = CreateSheet(workbook);

            var allStyles = ReportUtilities.CreateStyles(workbook);

            ReportUtilities.ExportReportHeader(title, sheet, allStyles, ref rowNumber);
            ExportReportSubheader(sheet, filter, allStyles, ref rowNumber);

            ExportReportValues(report, sheet, allStyles, ref rowNumber);
            ExportReportTshirts(report, sheet, allStyles, ref rowNumber);
            ExportReportFees(report, sheet, allStyles, ref rowNumber);
            ExportReportCharges(report, sheet, allStyles, ref rowNumber);

            //Write the workbook to a memory stream
            var output = new MemoryStream();

            workbook.Write(output);

            //Return the result to the end user

            return(File(output.ToArray(),           //The binary data of the XLS file
                        "application/vnd.ms-excel", //MIME type of Excel files
                        filename));                 //Suggested file name in the "Save as" dialog which will be displayed to the end user
        }
Example #2
0
        private FileResult ExportSummaryReport(vmEventManager_SummaryReport report, vmEventManager_EventFilter filter)
        {
            int rowNumber = 0;

            NPOI.SS.UserModel.IRow row;

            //Create new Excel workbook
            var workbook = new HSSFWorkbook();

            //Create new Excel sheet
            var sheet = workbook.CreateSheet();

            sheet.SetColumnWidth(0, 11 * 256);
            sheet.SetColumnWidth(1, 44 * 256);
            sheet.SetColumnWidth(2, 33 * 256);
            sheet.SetColumnWidth(3, 11 * 256);
            sheet.SetColumnWidth(4, 11 * 256);

            var allStyles = ReportUtilities.CreateStyles(workbook);

            ReportUtilities.ExportReportHeader("Summary Report", sheet, allStyles, ref rowNumber);
            if (filter.EventId != null)
            {
                var thisEvent = _service.GetEventById(filter.EventId.Value);

                row = sheet.CreateRow(rowNumber++);
                ReportUtilities.CreateCell(row, 0, string.Format("{0} - {1}", thisEvent.GeneralLocality, thisEvent.EventDates.Min().DateOfEvent.ToShortDateString()), allStyles.Header2Style);
            }
            sheet.CreateRow(rowNumber++);
            row = sheet.CreateRow(rowNumber++);
            ReportUtilities.CreateCell(row, 0, "Location", allStyles.TitleStyle);
            ReportUtilities.CreateCell(row, 1, "Wave Number", allStyles.TitleStyle);
            ReportUtilities.CreateCell(row, 2, "Start Time", allStyles.TitleStyle);
            ReportUtilities.CreateCell(row, 3, "Num Participants", allStyles.TitleStyle);
            ReportUtilities.CreateCell(row, 4, "Active", allStyles.TitleStyle);
            foreach (var wave in report.WaveData)
            {
                row = sheet.CreateRow(rowNumber++);
                ReportUtilities.CreateCell(row, 0, report.EventName, allStyles.LeftAligned);
                ReportUtilities.CreateCell(row, 1, wave.WaveNumber, allStyles.RightAligned);
                ReportUtilities.CreateCell(row, 2, wave.StartTime.ToString("MM/dd/yyyy HH:mm"), allStyles.RightAligned);
                ReportUtilities.CreateCell(row, 3, wave.NumParticipants, allStyles.RightAligned);
                ReportUtilities.CreateCell(row, 4, wave.Active, allStyles.LeftAligned);
            }

            //Write the workbook to a memory stream
            var output = new MemoryStream();

            workbook.Write(output);

            //Return the result to the end user

            return(File(output.ToArray(),           //The binary data of the XLS file
                        "application/vnd.ms-excel", //MIME type of Excel files
                        "SummaryExport.xls"));      //Suggested file name in the "Save as" dialog which will be displayed to the end user
        }
Example #3
0
        private FileResult ExportDetailedReport(vmEventManager_DetailedReport report, vmEventManager_EventFilter filter)
        {
            int rowNumber = 0;

            NPOI.SS.UserModel.IRow row;

            //Create new Excel workbook
            var workbook = new HSSFWorkbook();

            //Create new Excel sheet
            int col   = 0;
            var sheet = workbook.CreateSheet();

            sheet.SetColumnWidth(col++, 22 * 256);
            sheet.SetColumnWidth(col++, 22 * 256);
            sheet.SetColumnWidth(col++, 33 * 256);
            sheet.SetColumnWidth(col++, 33 * 256);
            sheet.SetColumnWidth(col++, 33 * 256);
            sheet.SetColumnWidth(col++, 22 * 256);
            sheet.SetColumnWidth(col++, 44 * 256);
            sheet.SetColumnWidth(col++, 44 * 256);
            sheet.SetColumnWidth(col++, 11 * 256);
            sheet.SetColumnWidth(col++, 15 * 256);
            sheet.SetColumnWidth(col++, 15 * 256);
            sheet.SetColumnWidth(col++, 18 * 256);

            var allStyles = ReportUtilities.CreateStyles(workbook);

            ReportUtilities.ExportReportHeader("Detailed Report", sheet, allStyles, ref rowNumber);
            if (filter.EventId != null)
            {
                var thisEvent = _service.GetEventById(filter.EventId.Value);

                row = sheet.CreateRow(rowNumber++);
                ReportUtilities.CreateCell(row, 0, string.Format("{0} - {1}", thisEvent.GeneralLocality, thisEvent.EventDates.Min().DateOfEvent.ToShortDateString()), allStyles.Header2Style);
            }
            sheet.CreateRow(rowNumber++);
            row = sheet.CreateRow(rowNumber++);
            col = 0;
            ReportUtilities.CreateCell(row, col++, "Location", allStyles.TitleStyle);
            ReportUtilities.CreateCell(row, col++, "Start Time", allStyles.TitleStyle);
            ReportUtilities.CreateCell(row, col++, "First Name", allStyles.TitleStyle);
            ReportUtilities.CreateCell(row, col++, "Last Name", allStyles.TitleStyle);
            ReportUtilities.CreateCell(row, col++, "Emergency Contact", allStyles.TitleStyle);
            ReportUtilities.CreateCell(row, col++, "Emergency Phone", allStyles.TitleStyle);
            ReportUtilities.CreateCell(row, col++, "Medical Information", allStyles.TitleStyle);
            ReportUtilities.CreateCell(row, col++, "Special Needs", allStyles.TitleStyle);
            ReportUtilities.CreateCell(row, col++, "Shirt Size", allStyles.TitleStyle);
            ReportUtilities.CreateCell(row, col++, "Agreed Legal", allStyles.TitleStyle);
            ReportUtilities.CreateCell(row, col++, "Agreed Trademark", allStyles.TitleStyle);
            ReportUtilities.CreateCell(row, col++, "ConfirmationCode", allStyles.TitleStyle);

            foreach (var wave in report.WaveData)
            {
                col = 0;
                row = sheet.CreateRow(rowNumber++);
                ReportUtilities.CreateCell(row, col++, report.EventName, allStyles.LeftAligned);
                ReportUtilities.CreateCell(row, col++, wave.StartTime.ToString("MM/dd/yyyy HH:mm"), allStyles.RightAligned);
                ReportUtilities.CreateCell(row, col++, wave.Firstname, allStyles.LeftAligned);
                ReportUtilities.CreateCell(row, col++, wave.Lastname, allStyles.LeftAligned);
                ReportUtilities.CreateCell(row, col++, wave.EmergencyContact, allStyles.LeftAligned);
                ReportUtilities.CreateCell(row, col++, wave.EmergencyPhone, allStyles.LeftAligned);
                ReportUtilities.CreateCell(row, col++, wave.MedicalInformation, allStyles.LeftAligned);
                ReportUtilities.CreateCell(row, col++, wave.SpecialNeeds, allStyles.LeftAligned);
                ReportUtilities.CreateCell(row, col++, wave.ShirtSize, allStyles.LeftAligned);
                ReportUtilities.CreateCell(row, col++, wave.AgreedLegal, allStyles.LeftAligned);
                ReportUtilities.CreateCell(row, col++, wave.AgreedTrademark, allStyles.LeftAligned);
                ReportUtilities.CreateCell(row, col++, wave.ConfirmationCode, allStyles.LeftAligned);
            }

            //Write the workbook to a memory stream
            var output = new MemoryStream();

            workbook.Write(output);

            //Return the result to the end user

            return(File(output.ToArray(),           //The binary data of the XLS file
                        "application/vnd.ms-excel", //MIME type of Excel files
                        "DetailedExport.xls"));     //Suggested file name in the "Save as" dialog which will be displayed to the end user
        }