ZimmertyZim
03/05/2024, 10:57 AMcsharp
private void ContentService_Published(Umbraco.Core.Services.IContentService sender, Umbraco.Core.Events.ContentPublishedEventArgs e)
{
// do stuff to get my content and save the excel file
if (downloadOnPublish)
{
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
HttpContext.Current.Response.AddHeader("Content-Disposition", $"attachment; filename=myExcelFile.xlsx");
byte[] fileBytes = System.IO.File.ReadAllBytes(filePath);
HttpContext.Current.Response.BinaryWrite(fileBytes);
HttpContext.Current.Response.End();
}
}
A hub and casual space for you to interact with fellow community members and learn more about Umbraco!
Powered by