using HotelPms.Share.Windows.Util; using HotelPms.SourceFactory.Table; using System.Text; namespace HotelPms.SourceFactory.Util; public class EnumFactory { public static string Create(string path, int sheetIndex) { StringBuilder text = new(); using NPOIExcel excel = new(path); excel.SetCurrentSheet(sheetIndex); bool start = false; for (int i = 0; i < excel.Sheet.LastRowNum; i++) { string line = excel.GetCellString($"B{i+1}"); if(line.Length > 0 && line.Substring(0,1) == "■") { int p1 = line.IndexOf('('); int p2 = line.IndexOf(')'); string name = line.Substring(p1 + 1, p2 - p1 - 1); text.Append(Environment.NewLine); text.AppendLine($"public enum {name} : int"); text.AppendLine("{"); start = true; } else { if (start) { string itemLine = excel.GetCellString($"C{i + 1}").Trim(); if (itemLine.Length == 0) { text.AppendLine("}"); start = false; } else if (itemLine == "名称") { continue; } else { text.AppendLine($"[Description(\"{excel.GetCellString($"R{i + 1}").Trim()}\")]"); text.AppendLine($"{itemLine} = {excel.GetCellInt($"O{i + 1}")},"); } } } } return text.ToString(); } }