예제 #1
0
        /// <see cref="ITableauViewModel.ExportToExcel"/>
        public async Task ExportToExcel()
        {
            try
            {
                string fileName = TableauSelected.NomDuTableau + ".xlsx";

                using (var memStream = new MemoryStream())
                {
                    using (var package = new ExcelPackage(memStream))
                    {
                        ExcelWorksheet sheet = package.Workbook.Worksheets.Add("Ma Feuille");

                        CreateColonnes(sheet, TableauSelected);
                        AddValues(sheet, ToutesLesEntrees);

                        byte[] fileTemp = package.GetAsByteArray();
                        await DownloadFileService.DownloadFile(fileName, fileTemp, "application/octet-stream");
                    }
                }
            }
            catch (Exception ex)
            {
                string errorMsg = "Erreur sur l'export du fichier Excel";
                Log.Error(ex, errorMsg);
                _notificationService.Notify(NotificationSeverity.Error, "Erreur", errorMsg, 3000);
            }
        }
예제 #2
0
        public async Task ShareFile(string file, string title)
        {
            var bytes = await File.ReadAllBytesAsync(file);

            await _blazorDownloadFileService.DownloadFile(title, bytes, CancellationToken.None, "application-octet-stream");
        }