Skip to content

Commit

Permalink
Updates to README
Browse files Browse the repository at this point in the history
  • Loading branch information
sveinungf committed Apr 14, 2024
1 parent a5c783b commit 9b64632
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ SpreadCheetah is a high-performance .NET library for generating spreadsheet (Mic
- Low memory allocation (see benchmarks below)
- Async APIs
- No dependency to Microsoft Excel
- Targeting .NET Standard 2.0 (for .NET Framework 4.6.1 and later)
- Native AOT compatible
- Free and open source!
- Targeting .NET Standard 2.0 for .NET Framework and earlier versions of .NET Core
- Targeting .NET 6 and newer for more optimizations
- Trimmable and native AOT compatible
- MIT license

SpreadCheetah is designed to create spreadsheet files in a forward-only manner.
That means worksheets from left to right, rows from top to bottom, and row cells from left to right.
Expand Down Expand Up @@ -78,24 +79,26 @@ using SpreadCheetah.SourceGeneration;
namespace MyNamespace;

[WorksheetRow(typeof(MyObject))]
public partial class MyObjectRowContext : WorksheetRowContext
{
}
public partial class MyObjectRowContext : WorksheetRowContext;
```

During build, the type will be analyzed and an implementation of the context class will be created. We can then create a row from an object by calling `AddAsRowAsync` with the object and the context type as parameters:
```cs
await using var spreadsheet = await Spreadsheet.CreateNewAsync(stream);
await spreadsheet.StartWorksheetAsync("Sheet 1");

var myObj = new MyObject { Question = "How many Rings of Power were there?", Answer = 20 };
var myObj = new MyObject
{
Question = "How many Rings of Power were there?",
Answer = 20
};

await spreadsheet.AddAsRowAsync(myObj, MyObjectRowContext.Default.MyObject);

await spreadsheet.FinishAsync();
```

Here is a peek at part of the code that was generated for this example:
Here is a peek at part of the code that was generated for this example. As you can see, the generated code also takes advantage of using a pooled array to avoid memory allocations:
```cs
// <auto-generated />
private static async ValueTask AddAsRowInternalAsync(Spreadsheet spreadsheet, MyObject obj, CancellationToken token)
Expand Down Expand Up @@ -180,6 +183,6 @@ The code is available [in the Benchmark project](https://github.com/sveinungf/sp
|----------------------------|-------------:|--------------:|
| **SpreadCheetah** | **23.07 ms** | **6.44 KB** |
| Open XML (SAX approach) | 184.94 ms | 66 041.63 KB |
| EPPlus v4 | 370.07 ms | 195 610.91 KB |
| EPPlusFree | 370.07 ms | 195 610.91 KB |
| Open XML (DOM approach) | 700.73 ms | 182 916.73 KB |
| ClosedXML | 754.83 ms | 529 203.20 KB |

0 comments on commit 9b64632

Please sign in to comment.