예제 #1
0
        private static IEnumerable <Entry> LoadIds(OfficeVersion officeVersion, OfficeApplication officeApplication)
        {
            var folder = Path.Combine(
                Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),
                "OfficeData",
                officeVersion.ToString());

            var files = new DirectoryInfo(folder).GetFiles("*.xlsx")
                        .Where(f => f.Name.StartsWith(officeApplication.ToString(), StringComparison.OrdinalIgnoreCase));

            foreach (var file in files)
            {
                using (var package = new ExcelPackage(file))
                {
                    var ws = package.Workbook.Worksheets.First();
                    for (var r = 2; r <= ws.Dimension.End.Row; r++)
                    {
                        yield return(new Entry
                        {
                            Completion = new Completion(ws.Cells[r, 1].GetValue <string>()),
                            ControlType = ws.Cells[r, 2].GetValue <string>(),
                            TabSet = ws.Cells[r, 3].GetValue <string>(),
                            Tab = ws.Cells[r, 4].GetValue <string>(),
                            Group = ws.Cells[r, 5].GetValue <string>(),
                            ParentControl = ws.Cells[r, 6].GetValue <string>(),
                        });
                    }
                }
            }
        }