private static void SaveAnimaCharacter(AnimaCharacter character, FileInfo file) { using (ExcelPackage package = new ExcelPackage(file)) { ExcelWorkbook workbook = package.Workbook; ExcelWorksheet worksheet = workbook.Worksheets["Feuille de personnage"]; worksheet.Cells["B13"].Value = character.CurrentHp; worksheet.Cells["B19"].Value = character.CurrentFatigue; worksheet.Cells["U16"].Value = character.CurrentZeon; worksheet.Cells["Q22"].Value = character.CurrentPpp; worksheet.Cells["Z39"].Value = character.CurrentKi; worksheet.Cells["AK1"].Value = character.ImageUrl; package.Save(); } }
public static void LoadFromCurrentDirectory() { Stopwatch sw = new Stopwatch(); sw.Start(); string[] allFiles = Directory.GetFiles(savePath, "@*"); int cCount = 0; Console.WriteLine($"{DateTime.Now.ToString("HH:mm:ss", CultureInfo.CurrentCulture)} Loading characters: {cCount}/{allFiles.Length}"); foreach (string file in allFiles) { string mention = "<" + Path.GetFileNameWithoutExtension(file).Split('_').First() + ">"; using (Stream strm = File.Open(file, FileMode.Open)) { MemoryStream memoryStream = new MemoryStream(); strm.CopyTo(memoryStream); using (ExcelPackage package = new ExcelPackage(memoryStream)) { PlayableCharacter character = null; ExcelWorkbook workbook = package.Workbook; ExcelWorksheet worksheet = workbook.Worksheets["Feuille de personnage"]; if (worksheet != null)//Fiche de perso anima { character = new AnimaCharacter(worksheet, mention); } worksheet = workbook.Worksheets["Stat"]; if (worksheet != null)//Fiche de perso L5R => peut encore changer { character = new L5RCharacter(worksheet, mention); } Characters.Add(character); } } cCount++; Console.Clear(); Console.WriteLine($"{DateTime.Now.ToString("HH:mm:ss", CultureInfo.CurrentCulture)} Loading characters: {cCount}/{allFiles.Length}"); } sw.Stop(); Console.WriteLine($"{DateTime.Now.ToString("HH:mm:ss", CultureInfo.CurrentCulture)} All characters loaded in : {sw.ElapsedMilliseconds}ms"); }