* Added Logo to the output file

This commit is contained in:
2025-10-01 14:42:58 +02:00
parent 8cfded48ae
commit 9163f330aa
5 changed files with 30 additions and 5 deletions

View File

@@ -10,7 +10,7 @@ namespace FaKrosnoApi.Controllers;
[ApiController]
[Route("api/[controller]")]
public class ExcelGeneratorController(IWzHeaderService wzHeaderService, IMaterialTransactionService materialTransactionService, IConfiguration configuration) : Controller
public class ExcelGeneratorController(IWzHeaderService wzHeaderService, IWzClientService wzClientService, IMaterialTransactionService materialTransactionService, IConfiguration configuration) : Controller
{
[HttpGet("generate-meyle")]
public async Task GeneratePackListForMeyle(Guid packListId)
@@ -96,6 +96,7 @@ public class ExcelGeneratorController(IWzHeaderService wzHeaderService, IMateria
public async Task GeneratePackListForMarelli(Guid packListId)
{
WzHeaderDto wzHeader = await wzHeaderService.GetByIdMarelli(packListId);
WzClientDto? wzClient = await wzClientService.GetById(wzHeader.FK_Client ?? Guid.NewGuid());
MaterialTransactionDto? materialTransaction = await materialTransactionService.GetByWzNumber(wzHeader.WzRowsMarelli.First().WzNumber);
using ExcelEngine excelEngine = new ExcelEngine();
@@ -124,14 +125,24 @@ public class ExcelGeneratorController(IWzHeaderService wzHeaderService, IMateria
worksheet["A4"].Value = "Packing List nr";
worksheet["A4"].CellStyle = boldFontStyle;
worksheet["B4"].Value = string.Join(", ", wzHeader.WzRowsMeyle.Select(x => x.WzNumber).Distinct());
worksheet["B4"].Value = string.Join(", ", wzHeader.WzRowsMarelli.Select(x => x.WzNumber).Distinct());
worksheet["B4"].CellStyle = boldFontStyle;
worksheet["A6"].Value = "Date";
worksheet["A6"].CellStyle = boldFontStyle;
worksheet["B6"].DateTime = materialTransaction?.CreateDate ?? DateTime.Now;
if (!string.IsNullOrEmpty(wzClient?.LogoBase64))
{
byte[] logoBytes = Convert.FromBase64String(wzClient.LogoBase64);
worksheet.Range["D1:F6"].Merge();
using MemoryStream imageStream = new MemoryStream(logoBytes);
worksheet.Pictures.AddPicture(1, 4, imageStream);
}
int currentRow = 12;
for (int i = 0; i < mainHeaders.Count; i++)