TH1/ExcelExport/Program.cs
2025-11-21 17:44:58 +08:00

133 lines
3.9 KiB
C#

using System;
using System.IO;
using System.Linq;
namespace ExcelConfig
{
public class Program
{
static void Main(string[] args)
{
try
{
Console.WriteLine("=== Excel导表工具 (MemoryPack版本) ===");
if (args.Length == 0)
{
Console.WriteLine("请输入参数:");
Console.WriteLine(" 1 - 导出CS文件");
Console.WriteLine(" 2 - 导出二进制文件");
Console.WriteLine(" 3 - 移动文件到目标目录");
return;
}
string command = args[0].ToLower();
Console.WriteLine($"执行操作: {command}");
Console.WriteLine();
switch (command)
{
case "1":
Console.WriteLine("开始导出CS文件...");
ExcelExporter.ExportCS();
break;
case "2":
Console.WriteLine("开始导出二进制文件...");
ExcelExporter.ExportBytes();
break;
case "3":
Console.WriteLine("开始移动文件...");
ExcelExporter.MoveFile();
break;
default:
Console.WriteLine($"未知命令: {command}");
Console.WriteLine("支持的命令: 1, 2, 3");
return;
}
Console.WriteLine();
Console.WriteLine("=== 操作完成 ===");
}
catch (Exception e)
{
Console.WriteLine();
Console.WriteLine($"错误: {e.Message}");
Console.WriteLine($"详细信息: {e}");
Environment.Exit(1);
}
}
}
}
// using MemoryPack;
// using OfficeOpenXml;
//
//
// namespace ExcelExport
// {
// [MemoryPackable]
// public partial class AIConfigCategory : IExcelConfig
// {
// [MemoryPackInclude]
// public Dictionary<int, AIConfig> Dict { get; set; } = new();
//
//
// public void Serialization(ExcelPackage p)
// {
// ExcelWorksheet worksheet = p.Workbook.Worksheets.First();
//
// // 获取最大行数
// int maxRow = worksheet.Dimension.End.Row;
//
// // 从第6行开始遍历
// for (int row = 6; row <= maxRow; row++)
// {
// var data = new AIConfig(worksheet.Cells, row);
// Dict[data.Id] = data;
// }
// }
// }
//
//
// [MemoryPackable]
// public partial class AIConfig
// {
// /// <summary>唯一ID</summary>
// [MemoryPackInclude]
// public int Id { get; set; }
// /// <summary>所属ai</summary>
// [MemoryPackInclude]
// public int AIConfigId { get; set; }
// /// <summary>此ai中的顺序</summary>
// [MemoryPackInclude]
// public int Order { get; set; }
// /// <summary>节点名字</summary>
// [MemoryPackInclude]
// public string Name { get; set; }
// /// <summary>节点参数</summary>
// [MemoryPackInclude]
// public int[] NodeParams { get; set; }
//
//
// [MemoryPackConstructor]
// public AIConfig()
// {
//
// }
//
// public AIConfig(ExcelRange cells, int row)
// {
// Id = (int)ExcelExporter.ConvertValue(cells[row, 3].Text.Trim(), typeof(int));
// AIConfigId = (int)ExcelExporter.ConvertValue(cells[row, 4].Text.Trim(), typeof(int));
// Order = (int)ExcelExporter.ConvertValue(cells[row, 5].Text.Trim(), typeof(int));
// Name = (string)ExcelExporter.ConvertValue(cells[row, 6].Text.Trim(), typeof(string));
// NodeParams = (int[])ExcelExporter.ConvertValue(cells[row, 7].Text.Trim(), typeof(int[]));
// }
// }
// }