-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathLMS.Helper.Reports.pas
100 lines (80 loc) · 2.2 KB
/
LMS.Helper.Reports.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
unit LMS.Helper.Reports;
interface
uses
Generics.Collections,
LMS._interface.LMS;
procedure ExportToExcel(const aLMSCourse: ICourse);
procedure ExportToExcelCourses(const aLMS: ILMS);
implementation
uses
LMS.Helper.Utils,
LMS.Helper.Excel;
procedure ExportToExcel(const aLMSCourse: ICourse);
var
ExcelWS: TExcelWorkSpace;
begin
ExcelWS := TExcelWorkSpace.Create;
try
ExcelWS.fXLWS.Cells.item[1, 1] := aLMSCourse.ShortName;
ExcelWS.fXLWS.Cells.item[1, 3] := aLMSCourse.FullName;
var
aRow := 5;
if aLMSCourse.UserGroups.Count > 0 then
begin
for var aGroup in aLMSCourse.UserGroups do
begin
ExcelWS.fXLWS.Cells.item[aRow, 2] := aGroup.Group_Name;
inc(aRow);
for var aUser in aGroup.UsersInGroup do
begin
ExcelWS.fXLWS.Cells.item[aRow, 3] := aUser.First_Name;
ExcelWS.fXLWS.Cells.item[aRow, 4] := aUser.Last_Name;
ExcelWS.fXLWS.Cells.item[aRow, 5] := aUser.UserName;
inc(aRow);
end;
end;
end
else
begin
for var aUser in aLMSCourse.Users do
begin
ExcelWS.fXLWS.Cells.item[aRow, 3] := aUser.First_Name;
ExcelWS.fXLWS.Cells.item[aRow, 4] := aUser.Last_Name;
ExcelWS.fXLWS.Cells.item[aRow, 5] := aUser.UserName;
inc(aRow);
end;
end;
finally
ExcelWS.ShowAndFinally;
end;
end;
procedure ExportToExcelCourses(const aLMS: ILMS);
var
ExcelWS: TExcelWorkSpace;
category: ICategory;
course: ICourse;
begin
ExcelWS := TExcelWorkSpace.Create;
try
ExcelWS.fXLWS.Cells.item[1, 1] := aLMS.Id;
var
aRow := 5;
for category in aLMS.Categories do
begin
ExcelWS.fXLWS.Cells.item[aRow, 1] := category.Id;
ExcelWS.fXLWS.Cells.item[aRow, 2] := category.Name;
inc(aRow);
for course in category.Courses do
begin
ExcelWS.fXLWS.Cells.item[aRow, 2] := course.Id;
ExcelWS.fXLWS.Cells.item[aRow, 3] := course.DisplayName;
ExcelWS.fXLWS.Cells.item[aRow, 4] := FormatDateTimeBlank(course.StartDate);
ExcelWS.fXLWS.Cells.item[aRow, 5] := FormatDateTimeBlank(course.EndDate);
inc(aRow);
end;
end;
finally
ExcelWS.ShowAndFinally;
end;
end;
end.