To ensure the browser treats the byte array as a downloadable Excel document, pay attention to these parameters:
The most efficient way in ASP.NET Core MVC or Web API is to use the native File() helper method. This method automatically handles the response stream and sets the necessary headers for the browser to trigger a download. download byte array as excel file c#
If you don't already have a byte array and need to create one from a data source, several C# libraries simplify the process: Dynamics community To ensure the browser treats the byte array