* Added Logo to the output file
This commit is contained in:
@@ -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++)
|
||||
|
||||
@@ -14,4 +14,11 @@ public class WzClientController(IWzClientService service) : Controller
|
||||
IEnumerable<WzClientDto> wzClients = await service.GetAll();
|
||||
return Ok(wzClients);
|
||||
}
|
||||
|
||||
[HttpGet("by-id")]
|
||||
public async Task<ActionResult<WzClientDto>> GetById(Guid id)
|
||||
{
|
||||
WzClientDto? wzClient = await service.GetById(id);
|
||||
return Ok(wzClient);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user