// création du premier fichier d'audit
 void CreateSpreadSheet(string outputFileName)
 {
     using (var spreadSheet = new SpreadSheetFile(outputFileName)) {
         CreateGraphSheet(spreadSheet, SheetNames.Graph);
         CreateSummarySheet(spreadSheet, SheetNames.Summary, DateTime.UtcNow.Year);
         CreateAuditTrailSheet(spreadSheet, SheetNames.AuditTrail);
         spreadSheet.Save();
     }
 }
        // génération du fichier de sortie
        async Task WriteAuditInfo(List <AuditLog> audits)
        {
            if (audits != null && audits.Count > 0)
            {
                var guids = new Dictionary <string, string>();
                for (var i = 0; i < audits.Count; i++)
                {
                    guids.Clear();
                    var audit = audits[i];

                    var symbols = new Dictionary <string, string>()
                    {
                        { "companyid", audit.CompanyId },
                        { "timestamp", DateTime.UtcNow.ToString("yyyyMMdd_HHmmss") }
                    };
                    var outputFileName = Template.ApplySymbols(_auditFile, symbols);

                    var dirName = Path.GetDirectoryName(outputFileName);
                    if (string.IsNullOrWhiteSpace(dirName))
                    {
                        dirName = ".";
                    }
                    outputFileName = Path.GetFullPath(Path.Combine(dirName, outputFileName));

                    if (!File.Exists(outputFileName))
                    {
                        if (!await ReusePreviousSpreadsheet(outputFileName))
                        {
                            CreateSpreadSheet(outputFileName);
                        }
                    }
                    _logger.Log($"Saving result to {outputFileName}");

                    using (var spreadSheet = new SpreadSheetFile(outputFileName)) {
                        var auditTrail = CreateAuditTrailSheet(spreadSheet, SheetNames.AuditTrail);
                        var colA       = spreadSheet.LoadColumnCells(auditTrail, "A");
                        for (var j = 0; j < colA.Count; j++)
                        {
                            var c    = colA[j];
                            var guid = spreadSheet.GetCellValue(c)?.ToString() ?? string.Empty;
                            if (!string.IsNullOrWhiteSpace(guid))
                            {
                                guids.Add(guid, null);
                            }
                        }
                        var maxRow = spreadSheet.GetMaxRow(colA);
                        foreach (var log in audit.Result.OrderBy(_ => _.date))
                        {
                            if (!guids.ContainsKey(log.Guid))
                            {
                                maxRow += 1;
                                spreadSheet.SetCellValue(auditTrail, "A", maxRow, log.Guid);
                                spreadSheet.SetCellValue(auditTrail, "B", maxRow, log.Date);
                                spreadSheet.SetCellValue(auditTrail, "C", maxRow, log.UserId);
                                spreadSheet.SetCellValue(auditTrail, "D", maxRow, log.Action);
                                auditTrail.Save();
                            }
                        }

                        spreadSheet.Save();
                    }
                }
            }
        }