add generate modlist feature
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
using Microsoft.Extensions.Primitives;
|
||||
using ModpackUpdater.Apps.Manager.Api.Model;
|
||||
using ModpackUpdater.Apps.Manager.LangRes;
|
||||
using ModpackUpdater.Apps.Manager.Ui;
|
||||
using ModpackUpdater.Manager;
|
||||
using OfficeOpenXml;
|
||||
using Pilz.UI.Extensions;
|
||||
using System.Text;
|
||||
using Telerik.WinControls.UI;
|
||||
@@ -209,4 +211,61 @@ internal static class SharedFunctions
|
||||
|
||||
return log.ToString().TrimEnd();
|
||||
}
|
||||
|
||||
public static ExcelPackage? GenerateModlist(InstallInfos installInfos)
|
||||
{
|
||||
var pkg = new ExcelPackage();
|
||||
var ws = pkg.Workbook.Worksheets.Add(GeneralLangRes.Text_Modlist);
|
||||
var cr = 1;
|
||||
var cc = 1;
|
||||
|
||||
// Header
|
||||
ws.Cells[cr, cc++].Value = ActionsListLangRes.Col_Name;
|
||||
ws.Cells[cr, cc++].Value = ActionsListLangRes.Col_SrcTag;
|
||||
ws.Cells[cr, cc++].Value = ActionsListLangRes.Col_Side;
|
||||
ws.Cells[cr, cc++].Value = ActionsListLangRes.Col_SrcType;
|
||||
ws.Cells[cr, cc++].Value = ActionsListLangRes.Col_SrcOwner;
|
||||
ws.Cells[cr, cc++].Value = ActionsListLangRes.Col_SrcName;
|
||||
cr += 1;
|
||||
cc = 1;
|
||||
|
||||
// Rows
|
||||
foreach (var action in installInfos.Actions)
|
||||
{
|
||||
if (action.IsExtra || action.IsZip || string.IsNullOrWhiteSpace(action.Id) || !action.Id.StartsWith("mod:"))
|
||||
continue;
|
||||
|
||||
var cellName = ws.Cells[cr, cc++];
|
||||
cellName.Value = action.Name;
|
||||
if (!string.IsNullOrWhiteSpace(action.Website))
|
||||
cellName.SetHyperlink(new Uri(action.Website));
|
||||
|
||||
var cellTag = ws.Cells[cr, cc++];
|
||||
cellTag.Value = action.SourceTag;
|
||||
if (!string.IsNullOrWhiteSpace(action.SourceUrl))
|
||||
cellTag.SetHyperlink(new Uri(action.SourceUrl));
|
||||
|
||||
ws.Cells[cr, cc++].Value = action.Side.ToString();
|
||||
ws.Cells[cr, cc++].Value = action.SourceType;
|
||||
ws.Cells[cr, cc++].Value = action.SourceOwner;
|
||||
ws.Cells[cr, cc++].Value = action.SourceName;
|
||||
|
||||
cr += 1;
|
||||
cc = 1;
|
||||
}
|
||||
|
||||
// Styling
|
||||
cc = 1;
|
||||
ws.Column(cc++).Width = 30;
|
||||
ws.Column(cc++).Width = 15;
|
||||
ws.Column(cc++).Width = 10;
|
||||
ws.Column(cc++).Width = 20;
|
||||
ws.Column(cc++).Width = 20;
|
||||
ws.Column(cc++).Width = 30;
|
||||
var tableDef = ws.Tables.Add(ws.Cells[1, 1, cr - 1, cc - 1], "Table");
|
||||
tableDef.TableStyle = OfficeOpenXml.Table.TableStyles.Medium16;
|
||||
tableDef.ShowHeader = true;
|
||||
|
||||
return pkg;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user