-
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #64 from sveinungf/dev/xmlwriter-iterator
WorksheetStartXml iterator
- Loading branch information
Showing
11 changed files
with
183 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
using BenchmarkDotNet.Attributes; | ||
using BenchmarkDotNet.Jobs; | ||
using SpreadCheetah.Worksheets; | ||
|
||
namespace SpreadCheetah.Benchmark.Benchmarks; | ||
|
||
[SimpleJob(RuntimeMoniker.Net80)] | ||
[MemoryDiagnoser] | ||
public class MultipleWorksheets | ||
{ | ||
private static readonly SpreadCheetahOptions Options = new() { DefaultDateTimeFormat = null }; | ||
|
||
[Benchmark] | ||
public async Task SpreadCheetah() | ||
{ | ||
await using var spreadsheet = await Spreadsheet.CreateNewAsync(Stream.Null, Options); | ||
var worksheetOptions = new WorksheetOptions(); | ||
worksheetOptions.Column(1).Width = 100; | ||
worksheetOptions.Column(2).Hidden = false; | ||
|
||
for (var i = 0; i < 1000; ++i) | ||
{ | ||
if (i % 2 == 0) | ||
{ | ||
await spreadsheet.StartWorksheetAsync(i.ToString()); | ||
continue; | ||
} | ||
|
||
worksheetOptions.FrozenColumns = i % 4 == 0 ? 1 : null; | ||
worksheetOptions.FrozenRows = i % 8 == 0 ? 1 : null; | ||
worksheetOptions.Visibility = i % 16 == 0 ? WorksheetVisibility.Hidden : WorksheetVisibility.Visible; | ||
worksheetOptions.Column(2).Hidden = i % 32 == 0; | ||
|
||
await spreadsheet.StartWorksheetAsync(i.ToString(), worksheetOptions); | ||
} | ||
|
||
await spreadsheet.FinishAsync(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
namespace SpreadCheetah.Test.Helpers; | ||
|
||
internal sealed class DoubleEqualityComparer(double tolerance) : IEqualityComparer<double> | ||
{ | ||
public bool Equals(double x, double y) => Math.Abs(x - y) <= tolerance; | ||
public int GetHashCode(double obj) => obj.GetHashCode(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
SpreadCheetah.TestHelpers/Collections/ClosedXmlWorksheetList.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using ClosedXML.Excel; | ||
using SpreadCheetah.TestHelpers.Assertions; | ||
using System.Collections; | ||
|
||
namespace SpreadCheetah.TestHelpers.Collections; | ||
|
||
internal sealed class ClosedXmlWorksheetList(XLWorkbook workbook) : IWorksheetList | ||
{ | ||
private readonly List<ISpreadsheetAssertSheet> _list = | ||
[ | ||
.. workbook.Worksheets.Select(x => new ClosedXmlAssertSheet(workbook, x)) | ||
]; | ||
|
||
public ISpreadsheetAssertSheet this[int index] => _list[index]; | ||
public int Count => _list.Count; | ||
public IEnumerator<ISpreadsheetAssertSheet> GetEnumerator() => _list.GetEnumerator(); | ||
IEnumerator IEnumerable.GetEnumerator() => _list.GetEnumerator(); | ||
|
||
public void Dispose() => workbook.Dispose(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
using SpreadCheetah.TestHelpers.Assertions; | ||
|
||
namespace SpreadCheetah.TestHelpers.Collections; | ||
|
||
public interface IWorksheetList : IReadOnlyList<ISpreadsheetAssertSheet>, IDisposable; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters