50 lines
1.5 KiB
C#
50 lines
1.5 KiB
C#
using OfficeOpenXml;
|
|
using MemoryPack;
|
|
|
|
|
|
namespace ExcelConfig
|
|
{
|
|
public partial class MomentCategory
|
|
{
|
|
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 Moment(worksheet.Cells, row);
|
|
Dict[data.Id] = data;
|
|
}
|
|
}
|
|
|
|
public override byte[] GetData()
|
|
{
|
|
return MemoryPackSerializer.Serialize(Dict);
|
|
}
|
|
}
|
|
|
|
|
|
public partial class Moment
|
|
{
|
|
public Moment(ExcelRange cells, int row)
|
|
{
|
|
Id = (int)ExcelExporter.ConvertValue(cells[row, 3].Text.Trim(), typeof(int));
|
|
MomentSubType = (String)ExcelExporter.ConvertValue(cells[row, 4].Text.Trim(), typeof(String));
|
|
BigId = (int)ExcelExporter.ConvertValue(cells[row, 5].Text.Trim(), typeof(int));
|
|
MomentMainType = (String)ExcelExporter.ConvertValue(cells[row, 6].Text.Trim(), typeof(String));
|
|
MediumId = (int)ExcelExporter.ConvertValue(cells[row, 7].Text.Trim(), typeof(int));
|
|
SmallId = (int)ExcelExporter.ConvertValue(cells[row, 8].Text.Trim(), typeof(int));
|
|
tmpDesc = (String)ExcelExporter.ConvertValue(cells[row, 9].Text.Trim(), typeof(String));
|
|
Title = (String)ExcelExporter.ConvertValue(cells[row, 10].Text.Trim(), typeof(String));
|
|
Desc = (String)ExcelExporter.ConvertValue(cells[row, 11].Text.Trim(), typeof(String));
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
|