private void PrintCourses(ISheet sheet, List <Course> courses)
        {
            foreach (Course course in courses)
            {
                foreach (DayOfWeek meetingDay in course.MeetingDays)
                {
                    int column   = DayMap[meetingDay];
                    int startRow = GetRowForTime(course.StartTime.Value);
                    int endRow   = GetRowForTime(course.EndTime.Value);


                    //Get cell
                    var row  = sheet.GetRow(startRow);
                    var cell = row.GetCell(column);

                    // Style cell
                    cell.CellStyle = ClassScheduleTemplate.GetCellStyle(_workbook, course.Color());

                    var cellValue = getCourseLabel(course);
                    cell.SetCellValue(cellValue);
                    sheet.AutoSizeColumn(column, true);

                    CellRangeAddress cellRange = new CellRangeAddress(startRow, endRow, column, column);
                    var regionIndex            = sheet.AddMergedRegion(cellRange);
                }
            }
        }
示例#2
0
        /// <summary>
        /// Prints legend of the depertments by side of the schedule for a room.
        /// </summary>
        /// <param name="sheet">A Microsoft Excel sheet.</param>
        private void printLegend(ISheet sheet)
        {
            CellReference cellReference = new CellReference("J5");
            int           rowIndex      = cellReference.Row;
            int           cellIndex     = cellReference.Col;

            Dictionary <string, short> subjectColorMap = Template.GetSubjectColorMap();

            foreach (var entry in subjectColorMap)
            {
                IRow  row  = sheet.GetRow(rowIndex);
                ICell cell = row.GetCell(cellIndex);
                cell.CellStyle = Template.GetCellStyle(_workbook, (string)entry.Key);
                cell.SetCellValue((string)entry.Key);
                rowIndex++;
            }
        }
        private void printLegend(ISheet sheet)
        {
            CellReference cellReference = new CellReference("J5");
            int           rowIndex      = cellReference.Row;
            int           cellIndex     = cellReference.Col;

            OrderedDictionary subjectColorMap = ClassScheduleTemplate.GetSubjectColorMap();

            foreach (DictionaryEntry entry in subjectColorMap)
            {
                IRow  row  = sheet.GetRow(rowIndex);
                ICell cell = row.GetCell(cellIndex);
                cell.CellStyle = ClassScheduleTemplate.GetCellStyle(_workbook, (short)entry.Value);
                cell.SetCellValue((string)entry.Key);
                rowIndex++;
            }
        }