diff --git a/Projects/WebClient/Web.Tra/Components/App.razor b/Projects/WebClient/Web.Tra/Components/App.razor
index 2c2b0f4..07eac9a 100644
--- a/Projects/WebClient/Web.Tra/Components/App.razor
+++ b/Projects/WebClient/Web.Tra/Components/App.razor
@@ -16,6 +16,7 @@
+
diff --git a/Projects/WebClient/Web.Tra/Components/Pages/TRA.razor b/Projects/WebClient/Web.Tra/Components/Pages/TRA.razor
index e899e08..a4b4af4 100644
--- a/Projects/WebClient/Web.Tra/Components/Pages/TRA.razor
+++ b/Projects/WebClient/Web.Tra/Components/Pages/TRA.razor
@@ -4,6 +4,7 @@
@using System.Collections.Concurrent
@using System.Collections.Specialized
@using System.Collections
+@using ClosedXML.Excel
@using Web.Tra.Services
@inject CPXV2LogService CPXV2LogService
@inject PopupService PopupService
@@ -590,6 +591,50 @@
private async Task OnExportExcel()
{
-
+ var tab = Tabs.FirstOrDefault(x => x.Key.Id == SelectedTabIndex);
+ if(tab.Value?.Count > 0)
+ {
+ if (tab.Key.EnumTab == EnumTabs.OverviewC1 || tab.Key.EnumTab == EnumTabs.OverviewC1Detail || tab.Key.EnumTab == EnumTabs.OverviewC1Merged || tab.Key.EnumTab == EnumTabs.OverviewC1DetailMerged)
+ await ExportToExcelAsync(tab.Value.Cast());
+
+ if(tab.Key.EnumTab == EnumTabs.TestSummaryC1)
+ await ExportToExcelAsync(tab.Value.Cast());
+ }
+ }
+
+ public async Task ExportToExcelAsync(IEnumerable data, string fileName = "export.xlsx")
+ {
+ using var workbook = new XLWorkbook();
+ var worksheet = workbook.Worksheets.Add("Sheet1");
+
+ var properties = typeof(T).GetProperties();
+
+ // 헤더
+ for (int i = 0; i < properties.Length; i++)
+ {
+ worksheet.Cell(1, i + 1).Value = properties[i].Name;
+ }
+
+ // 데이터
+ int row = 2;
+ foreach (var item in data)
+ {
+ for (int col = 0; col < properties.Length; col++)
+ {
+ var value = properties[col].GetValue(item);
+ // if(value is int)
+ // worksheet.Cell(row, col + 1).Value = Convert.ToInt32(value);
+ // else if (value is double)
+ // worksheet.Cell(row, col + 1).Value = Convert.ToDouble(value);
+
+ worksheet.Cell(row, col + 1).Value = $" {value}";
+ }
+ row++;
+ }
+
+ using var stream = new MemoryStream();
+ workbook.SaveAs(stream);
+ var bytes = stream.ToArray();
+ await JS.InvokeVoidAsync("downloadFile", fileName, Convert.ToBase64String(bytes));
}
}
\ No newline at end of file
diff --git a/Projects/WebClient/Web.Tra/Model/Enum/EnumTabs.cs b/Projects/WebClient/Web.Tra/Model/Enum/EnumTabs.cs
index 20b4ce7..af423c4 100644
--- a/Projects/WebClient/Web.Tra/Model/Enum/EnumTabs.cs
+++ b/Projects/WebClient/Web.Tra/Model/Enum/EnumTabs.cs
@@ -3,6 +3,7 @@
public enum EnumTabs
{
None = 0,
+ Global = 1,
OverviewC1 = 10,
OverviewC1Merged = 11,
diff --git a/Projects/WebClient/Web.Tra/Web.Tra.csproj b/Projects/WebClient/Web.Tra/Web.Tra.csproj
index 5339b48..e3e599b 100644
--- a/Projects/WebClient/Web.Tra/Web.Tra.csproj
+++ b/Projects/WebClient/Web.Tra/Web.Tra.csproj
@@ -7,6 +7,7 @@
+
diff --git a/Projects/WebClient/Web.Tra/wwwroot/js/script.js b/Projects/WebClient/Web.Tra/wwwroot/js/script.js
new file mode 100644
index 0000000..c0498a8
--- /dev/null
+++ b/Projects/WebClient/Web.Tra/wwwroot/js/script.js
@@ -0,0 +1,8 @@
+window.downloadFile = (fileName, base64Data) => {
+ const link = document.createElement('a');
+ link.download = fileName;
+ link.href = "data:application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;base64," + base64Data;
+ document.body.appendChild(link);
+ link.click();
+ document.body.removeChild(link);
+};
\ No newline at end of file