From afe10ed3b062bb0535beba1f9651f9d5aae7f374 Mon Sep 17 00:00:00 2001 From: Userok Date: Mon, 28 Oct 2024 14:01:59 +0300 Subject: [PATCH] --- Zurnal/UI/conver.cs | 50 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 Zurnal/UI/conver.cs diff --git a/Zurnal/UI/conver.cs b/Zurnal/UI/conver.cs new file mode 100644 index 0000000..6f293cb --- /dev/null +++ b/Zurnal/UI/conver.cs @@ -0,0 +1,50 @@ +using System; +using System.Collections.Generic; +using System.Data; +using System.IO; +using OfficeOpenXml; + +class Conver +{ + static void Main() + { + var attendanceData = new Dictionary> + { + { "Группа 1", new Dictionary { { new DateTime(2023, 10, 1), true }, { new DateTime(2023, 10, 2), false } } }, + { "Группа 2", new Dictionary { { new DateTime(2023, 10, 1), true }, { new DateTime(2023, 10, 2), true } } } + }; + + using (ExcelPackage excel = new ExcelPackage()) + { + foreach (var group in attendanceData) + { + var worksheet = excel.Workbook.Worksheets.Add(group.Key); + worksheet.Cells[1, 1].Value = "ФИО"; + int column = 2; + + foreach (var date in group.Value.Keys) + { + worksheet.Cells[1, column].Value = date.ToShortDateString(); + column++; + } + + int row = 2; + foreach (var student in group.Value) + { + worksheet.Cells[row, 1].Value = student.Key; + column = 2; + + foreach (var date in group.Value.Keys) + { + worksheet.Cells[row, column].Value = group.Value[date] ? "Присутствует" : "Отсутствует"; + column++; + } + row++; + } + } + + FileInfo excelFile = new FileInfo(@"C:\Users\profi\source\Musor\Xcel"); + excel.SaveAs(excelFile); + } + } +}