Example #1
0
        private static Workbook GenerateExcel(SubjectRegister subjectRegister)
        {
            Workbook workbook = new Workbook();

            workbook.LoadFromFile("Files/Template.xlsx", ExcelVersion.Version2010);
            Worksheet worksheet = workbook.Worksheets[0];

            var students = subjectRegister.GetStudentList();

            worksheet.SetCellValue(4, 3, subjectRegister.Code + " " + subjectRegister.Id + " " + subjectRegister.Subject);
            worksheet.SetCellValue(5, 3, subjectRegister.Professor);
            worksheet.SetCellValue(6, 3, subjectRegister.StartDateString());
            worksheet.SetCellValue(7, 3, subjectRegister.EndDateString());

            int  count = 9;
            bool first = false;

            foreach (var student in students)
            {
                if (first)
                {
                    worksheet.InsertRow(count);
                    worksheet.Copy(worksheet.Range["A" + (count - 1).ToString() + ":J" + (count - 1).ToString()], worksheet.Range["A" + count.ToString() + ":J" + count.ToString()], true);
                }

                worksheet.SetCellValue(count, 1, student.Id.ToString());
                worksheet.SetCellValue(count, 3, student.Career);
                worksheet.SetCellValue(count, 4, student.FullName);
                first = true;
                count++;
            }
            worksheet.SetCellValue(count, 3, students.Count.ToString());
            return(workbook);
        }
Example #2
0
        public void AddSubjectRegister(SubjectList aSubjectList)
        {
            if (aSubjectList.getCount() == 0)
            {
                Console.WriteLine("\n ************************************************************************");
                Console.WriteLine("\t Para utilizar esta opcion debe agregar asignaturas.");
                Console.WriteLine("\n ************************************************************************");
            }
            else
            {
                var newSubjectRegister = new SubjectRegister();

                Console.WriteLine("\n Agregar registro de asignatura \n");
                Console.WriteLine("\t Asignaturas disponibles para creacion de registro de asignatura: \n");
                aSubjectList.ListSubjects();
                Console.Write("\n \n Escriba el ID de la asignatura con que desea crear nuevo registro de asignatura: ");
                int id = Convert.ToInt32("0" + Console.ReadLine());
                if (aSubjectList.GetIdList().Contains(id))
                {
                    newSubjectRegister.SetSubject(aSubjectList.SearchAndReturn(id));

                    newSubjectRegister.SetAtributes(lastId + 1);
                    lastId++;

                    this.subjectRegisters.Add(newSubjectRegister);
                }
                else
                {
                    Console.WriteLine("Id invalido.");
                }
            }
        }
Example #3
0
        public static void ExportPdf(SubjectRegister subjectRegister)
        {
            var workbook = GenerateExcel(subjectRegister);

            workbook.SaveToFile("Files/Registro.pdf", Spire.Xls.FileFormat.PDF);
        }
Example #4
0
        public static void ExportExcel(SubjectRegister subjectRegister)
        {
            var workbook = GenerateExcel(subjectRegister);

            workbook.SaveToFile("Files/Registro.xlsx", ExcelVersion.Version2010);
        }