加载Excel表格信息

    xiaoxiao2021-03-25  112

    引入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); } } }
    转载请注明原文地址: https://ju.6miu.com/read-15777.html

    最新回复(0)