Open augustoproiete opened 5 years ago
Opa! Alguém conseguiu resolver esse problema. Também só obtive a resposta em json.
Mas implementei de outra forma:
` [HttpGet]
[Route("{id}")]
public async Task
private async Task<XLWorkbook> BuildExcelFile(int id)
{
//Creating the workbook
var t = Task.Run(() =>
{
var wb = new XLWorkbook();
var ws = wb.AddWorksheet("Sheet1");
ws.FirstCell().SetValue(id);
return wb;
});
return await t;
}`
Following up from @Pankraty's comment on ClosedXML/#1283... Looking at the different ClosedXML extensions, it seems
ClosedXML.Extensions.AspNet
would be the most appropriate extension for ASP .NET Core Web API projects, so the below is just for awareness.Instead of the file being downloaded, we receive a text response:
Sample project that reproduces the above:
NuGet packages added to the project:
Example code from the README: