public async Task <byte[]> GenerateBulkUploadTemplate(Guid notificationId, BulkType bulkType)
        {
            var templateName = string.Empty;

            switch (bulkType)
            {
            case BulkType.Prenotification:
                templateName = "BulkUploadPrenotificationTemplate.xlsx";
                break;

            case BulkType.ReceiptRecovery:
                templateName = "BulkUploadReceiptRecoveryTemplate.xlsx";
                break;
            }

            using (var memoryStream = DocumentHelper.ReadDocumentStreamShared(templateName))
            {
                var notificatioNumber = await notificationApplicationRepository.GetNumber(notificationId);

                using (var document = SpreadsheetDocument.Open(memoryStream, true))
                {
                    var workbookPart = document.WorkbookPart;
                    var sheet        = workbookPart.Workbook.Descendants <Sheet>().FirstOrDefault();

                    if (sheet != null)
                    {
                        var worksheetPart = workbookPart.GetPartById(sheet.Id.Value) as WorksheetPart;

                        if (worksheetPart != null)
                        {
                            var cell = GetCell(worksheetPart.Worksheet, "A", 2);

                            cell.CellValue = new CellValue(notificatioNumber);
                            cell.DataType  = new EnumValue <CellValues>(CellValues.String);

                            worksheetPart.Worksheet.Save();
                        }
                    }
                }

                return(memoryStream.ToArray());
            }
        }
Esempio n. 2
0
 public GetBulkUploadTemplate(Guid notificationId, BulkType bulkType)
 {
     NotificationId = notificationId;
     BulkType       = bulkType;
 }