Download Excel Document to Web Client

I am trying to download an Excel document to a client browser. I used to use the following, but ContentDisposition.Attachment is no longer valid in .NET Core. I am using .NET Core 6. I’ve just spent a couple of hours trying to find the method for doing this.

_Excel.Save(response, string.Format("{0}.xlsx", strName), ContentDisposition.Attachment, new OoxmlSaveOptions(SaveFormat.Xlsx));

@FireWave,
In. NET Core 6, ContentDisposition.Attachment is no longer valid. You need to call Workbook.Save to save the file to the stream, and then operate the stream output to the client according to your situation.
Please refer to the following document.

Does the workbook that gets created in this process get deleted automatically, or do you need to delete it when finished?

@FireWave,

Aspose.Cells for .NET does not necessarily require to free up the resources for the processes as the component is already optimized to do so automatically. Aspose.Cells is created in managed C#, we do not use any un-managed code. When objects (such as Workbook or other relevant elements) are no more useful in the processes, GC would collect and release the memory occupied by the objects. Being a pure .NET component, Aspose.Cells for .NET relies on .NET garbage collector (GC) to allocate and free the memory for the different processes, although you may try to also use GC.Collect() or try using Workbook.Dispose() and set Workbook to null accordingly in some cases. Moreover, if you are using Stream objects, you may close it to manually release the resources for the objects when they are not used any longer.

Thank you that does what I need.

@FireWave,
You are welcome. If you have any questions, please feel free to contact us.