ClosedXML / ClosedXML/ClosedXML.Extensions.WebApi

ClosedXML Extensions WebAPI does not work with ASP .NET Core Web API

Open
#1 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
35
Forks
14
PR merge metrics
No merged PRs in 30d

Description

Following up from @Pankraty's [comment on ClosedXML/#1283](https://github.com/ClosedXML/ClosedXML/issues/1283#issuecomment-526469962)... Looking at the different ClosedXML extensions, it seems [`ClosedXML.Extensions.AspNet`](https://github.com/ClosedXML/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:

![image](https://user-images.githubusercontent.com/177608/64029097-4775c700-cb1a-11e9-8da2-06049fcb3bf4.png)

Sample project that reproduces the above:
* [TestClosedXMLWebApi.zip](https://github.com/ClosedXML/ClosedXML.Extensions.WebApi/files/3560345/TestClosedXMLWebApi.zip)

---

NuGet packages added to the project:

```xml

```

Example code from the [README](https://github.com/ClosedXML/ClosedXML.Extensions.WebApi#usage):

```csharp
[ApiController]
public class ExcelController : ControllerBase
{
[HttpGet]
[Route("api/file/{id}")]
public async Task DownloadFile(int id)
{
var wb = await BuildExcelFile(id);
return wb.Deliver("excelfile.xlsx");
}

private async Task BuildExcelFile(int id)
{
var t = Task.Run(() =>
{
var wb = new XLWorkbook();
var ws = wb.AddWorksheet("Sheet1");
ws.FirstCell().SetValue(id);

return wb;
});

return await t;
}
}
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.