46 lines
1.1 KiB
C#
46 lines
1.1 KiB
C#
using OfficeOpenXml;
|
|
using MemoryPack;
|
|
|
|
|
|
namespace ExcelConfig
|
|
{
|
|
public partial class AIConfigCategory
|
|
{
|
|
public override 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;
|
|
}
|
|
}
|
|
|
|
public override byte[] GetData()
|
|
{
|
|
return MemoryPackSerializer.Serialize(typeof(Dictionary<int, AIConfig>), Dict);
|
|
}
|
|
}
|
|
|
|
|
|
public partial class 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[]));
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
|