ClosedXML / ClosedXML/ClosedXML.Extensions.WebApi

Async code example in Readme

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

Description

```
private async Task 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;
}
```

instead of
```
private Task BuildExcelFile(int id)
{
//Creating the workbook
return Task.Run(() =>
{
var wb = new XLWorkbook();
var ws = wb.AddWorksheet("Sheet1");
ws.FirstCell().SetValue(id);

return wb;
});
}
```

and could be even
```
private XLWorkbook BuildExcelFile(int id)
{
//Creating the workbook
var wb = new XLWorkbook();
var ws = wb.AddWorksheet("Sheet1");
ws.FirstCell().SetValue(id);

return wb;
}
```
(and then Task.Run(...) in the main function)

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.