引入EPPlus 类库
using OfficeOpenXml;
//加载信息
private static void LoadInformation()
{
using (ExcelPackage package = new ExcelPackage(new FileInfo("charactor_config.xlsx")))
{
ExcelWorksheet sheet = package.Workbook.Worksheets["charactor"];
int rowStart = sheet.Dimension.Start.Row;
int rowEnd = sheet.Dimension.End.Row;
for (int i = rowStart + 1; i <= rowEnd; i++)
{
Card card = new Card();
card.Id = sheet.GetValue(i, 1).ToString();
card.Property = sheet.GetValue(i, 2).ToString();
card.Name = sheet.GetValue(i, 3).ToString();
card.Attack = sheet.GetValue(i, 4).ToString();
CardList.Add(card);
}
foreach (var item in CardList)
{
Console.WriteLine(item);
}
}
}