2024-10-28 11:01:59 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using OfficeOpenXml;
|
|
|
|
|
|
|
|
|
|
class Conver
|
|
|
|
|
{
|
|
|
|
|
static void Main()
|
|
|
|
|
{
|
|
|
|
|
var attendanceData = new Dictionary<string, Dictionary<DateTime, bool>>
|
|
|
|
|
{
|
2024-10-28 11:03:42 +00:00
|
|
|
|
{ "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 1", new Dictionary<DateTime, bool> { { new DateTime(2023, 10, 1), true }, { new DateTime(2023, 10, 2), false } } },
|
|
|
|
|
{ "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 2", new Dictionary<DateTime, bool> { { new DateTime(2023, 10, 1), true }, { new DateTime(2023, 10, 2), true } } }
|
2024-10-28 11:01:59 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
using (ExcelPackage excel = new ExcelPackage())
|
|
|
|
|
{
|
|
|
|
|
foreach (var group in attendanceData)
|
|
|
|
|
{
|
|
|
|
|
var worksheet = excel.Workbook.Worksheets.Add(group.Key);
|
2024-10-28 11:03:42 +00:00
|
|
|
|
worksheet.Cells[1, 1].Value = "<22><><EFBFBD>";
|
2024-10-28 11:01:59 +00:00
|
|
|
|
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)
|
|
|
|
|
{
|
2024-10-28 11:03:42 +00:00
|
|
|
|
worksheet.Cells[row, column].Value = group.Value[date] ? "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>" : "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>";
|
2024-10-28 11:01:59 +00:00
|
|
|
|
column++;
|
|
|
|
|
}
|
|
|
|
|
row++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FileInfo excelFile = new FileInfo(@"C:\Users\profi\source\Musor\Xcel");
|
|
|
|
|
excel.SaveAs(excelFile);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|