public Entity_sheet_Modified CreateSheetModifed(Entity_sheet1_Extra extra, [FolderPath] string input) { string exportPath = input.Replace(Path.GetFileName(input), $"{extra.name}.asset"); Entity_sheet_Modified data = (Entity_sheet_Modified)AssetDatabase.LoadAssetAtPath(exportPath, typeof(Entity_sheet_Modified)); if (data == null) { data = ScriptableObject.CreateInstance <Entity_sheet_Modified>(); AssetDatabase.CreateAsset((ScriptableObject)data, exportPath); // data.hideFlags = HideFlags.NotEditable; data.name = Path.GetFileNameWithoutExtension(exportPath); } if (data.sheets.Count > 0 && data.sheets[0].list.Count > 0) { Debug.Log($"{exportPath} will be overriden"); } data.sheets.Clear(); Entity_sheet_Modified.SheetModified sheet = new Entity_sheet_Modified.SheetModified(); sheet.name = extra.name; data.sheets.Add(sheet); for (int i = 0; i < extra.list.Count; i++) { ParamModified param = new ParamModified(extra.list[i]); data.sheets[0].list.Add(param); } ScriptableObject obj = AssetDatabase.LoadAssetAtPath(exportPath, typeof(ScriptableObject)) as ScriptableObject; EditorUtility.SetDirty(obj); return(data); }
public void FillDataIntoExcelSheet(HSSFSheet sheet) { AssignCombinedGroupColumn(); CalculateGroupStatistic(); List <ParamModified> list = sheets[0].list; HSSFRow row = (HSSFRow)sheet.CreateRow(0); int i = 0; HSSFCell cell = (HSSFCell)row.CreateCell((short)i); cell.SetCellValue("Description"); cell = (HSSFCell)row.CreateCell((short)++i); cell.SetCellValue("Combined Group"); cell = (HSSFCell)row.CreateCell((short)++i); cell.SetCellValue("Group"); cell = (HSSFCell)row.CreateCell((short)++i); cell.SetCellValue("Data Rows Count"); cell = (HSSFCell)row.CreateCell((short)++i); cell.SetCellValue("Count Unique UserID"); cell = (HSSFCell)row.CreateCell((short)++i); cell.SetCellValue("Count Unique MachineID"); cell = (HSSFCell)row.CreateCell((short)++i); cell.SetCellValue("Count License F"); cell = (HSSFCell)row.CreateCell((short)++i); cell.SetCellValue("Count License H"); cell = (HSSFCell)row.CreateCell((short)++i); cell.SetCellValue("IP"); cell = (HSSFCell)row.CreateCell((short)++i); cell.SetCellValue("LicenseHash"); cell = (HSSFCell)row.CreateCell((short)++i); cell.SetCellValue("MachineId"); cell = (HSSFCell)row.CreateCell((short)++i); cell.SetCellValue("Version"); cell = (HSSFCell)row.CreateCell((short)++i); cell.SetCellValue("Location"); cell = (HSSFCell)row.CreateCell((short)++i); cell.SetCellValue("Userid"); cell = (HSSFCell)row.CreateCell((short)++i); cell.SetCellValue("count"); cell = (HSSFCell)row.CreateCell((short)++i); cell.SetCellValue("SerialNumber"); cell = (HSSFCell)row.CreateCell((short)++i); cell.SetCellValue("LicenseType"); cell = (HSSFCell)row.CreateCell((short)++i); cell.SetCellValue("ShortVer"); for (int j = 0; j < list.Count; j++) { ParamModified param = list[j]; HSSFRow r = (HSSFRow)sheet.CreateRow(j + 1); param.FillDataIntoRow(r); } }
public void SheetToGroup() { List <ParamModified> list = sheets[0].list; if (list.Count == 0) { Debug.LogWarning("Nothing in list to process"); return; } Group group = new Group(); ParamModified previous = list[0]; group.rows.Add(previous); group.name = previous.Description; group.users = previous.users; group.machines = previous.machines; group.F = previous.F; group.H = previous.H; Debug.Log($"New group: {group.name}"); for (int i = 1; i < list.Count; i++) { ParamModified temp = list[i]; if (temp.group != previous.group) { if (!string.IsNullOrEmpty(previous.combinedGroup) && previous.combinedGroup.Equals(temp.combinedGroup)) { Debug.Log($"Merged group: {group.name}"); group.users += temp.users; group.machines += temp.machines; group.F += temp.F; group.H += temp.H; if (!string.IsNullOrEmpty(temp.Description)) { group.description += $"{temp.Description}\n"; } } else { groups.Add(group); group = new Group(); group.users = temp.users; group.machines = temp.machines; group.F = temp.F; group.H = temp.H; if (!string.IsNullOrEmpty(temp.Description)) { group.name = temp.Description; Debug.Log($"New group: {group.name}"); } } } else { if (!string.IsNullOrEmpty(temp.Description)) { group.description += $"{temp.Description}\n"; } } group.rows.Add(temp); previous = temp; } group.CalculateStatistic(); groups.Add(group); }
public Entity_sheet_Modified GenerateDataThatHasDescription([FilePath] string filePath) { string exportPath = filePath.Replace(Path.GetExtension(filePath), ".asset"); Entity_sheet_Modified data = (Entity_sheet_Modified)AssetDatabase.LoadAssetAtPath(exportPath, typeof(Entity_sheet_Modified)); if (data == null) { data = ScriptableObject.CreateInstance <Entity_sheet_Modified>(); AssetDatabase.CreateAsset((ScriptableObject)data, exportPath); // data.hideFlags = HideFlags.NotEditable; data.name = Path.GetFileNameWithoutExtension(filePath); } if (data.sheets.Count > 0 && data.sheets[0].list.Count > 0) { Debug.Log($"{exportPath} will be overriden"); } data.sheets.Clear(); using (FileStream stream = File.Open(filePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) { IWorkbook book = null; if (Path.GetExtension(filePath) == ".xls") { book = new HSSFWorkbook(stream); } else { book = new XSSFWorkbook(stream); } for (int j = 0; j < book.NumberOfSheets; j++) { ISheet sheet = book.GetSheetAt(j); if (sheet == null) { Debug.LogError("[QuestData] sheet not found:"); continue; } Entity_sheet_Modified.SheetModified s = new Entity_sheet_Modified.SheetModified(); s.name = sheet.SheetName; for (int i = 1; i <= sheet.LastRowNum; i++) { IRow row = sheet.GetRow(i); ICell cell = null; ParamModified p = new ParamModified(); int k = 0; cell = row.GetCell(k); p.Description = (cell == null ? "" : cell.StringCellValue.Trim()); cell = row.GetCell(++k); p.combinedGroup = (cell == null ? "" : cell.StringCellValue); cell = row.GetCell(++k); p.group = (int)(cell == null ? 0 : cell.NumericCellValue); cell = row.GetCell(++k); p.rows = (int)(cell == null ? 0 : cell.NumericCellValue); cell = row.GetCell(++k); p.users = (int)(cell == null ? 0 : cell.NumericCellValue); cell = row.GetCell(++k); p.machines = (int)(cell == null ? 0 : cell.NumericCellValue); cell = row.GetCell(++k); p.F = (int)(cell == null ? 0 : cell.NumericCellValue); cell = row.GetCell(++k); p.H = (int)(cell == null ? 0 : cell.NumericCellValue); cell = row.GetCell(++k); p.IP = (cell == null ? "" : cell.StringCellValue); cell = row.GetCell(++k); p.LicenseHash = (cell == null ? "" : cell.StringCellValue); cell = row.GetCell(++k); p.MachineId = (cell == null ? "" : cell.StringCellValue); cell = row.GetCell(++k); p.Version = (cell == null ? "" : cell.StringCellValue); cell = row.GetCell(++k); p.Location = (cell == null ? "" : cell.StringCellValue); cell = row.GetCell(++k); p.Userid = (cell == null ? 0.0 : cell.NumericCellValue); cell = row.GetCell(++k); p.count = (int)(cell == null ? 0 : cell.NumericCellValue); cell = row.GetCell(++k); p.SerialNumber = (cell == null ? "" : cell.StringCellValue); cell = row.GetCell(++k); p.LicenseType = (cell == null ? "" : cell.StringCellValue); cell = row.GetCell(++k); p.ShortVer = (cell == null ? "" : cell.StringCellValue); s.list.Add(p); } data.sheets.Add(s); } } ScriptableObject obj = AssetDatabase.LoadAssetAtPath(exportPath, typeof(ScriptableObject)) as ScriptableObject; EditorUtility.SetDirty(obj); Debug.Log($"Generate intermediate data: {exportPath}"); return(data); }
public ParamModified(ParamModified param) : base(param) { this.Description = param.Description.Trim(); this.combinedGroup = param.combinedGroup; }