Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,6 @@
*.fsproj -text merge=union
*.dbproj -text merge=union
*.sln -text merge=union
*.slnx -text merge=union

tests/data/** binary
2 changes: 1 addition & 1 deletion benchmarks/MiniExcel.Benchmarks/BenchmarkBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

public abstract class BenchmarkBase
{
protected const string FilePath = "Test100,000x10.xlsx";
protected const string FilePath = "data/Test100,000x10.xlsx";
protected const int RowCount = 100_000;

protected IEnumerable<DemoDto> GetValue() => Enumerable.Range(1, RowCount).Select(_ => new DemoDto());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,7 @@ public void OpenXmlSdkCreateByDomModeTest()

sheets.Append(new Sheet
{
Id = spreadsheetDocument.WorkbookPart.
GetIdOfPart(worksheetPart),
Id = spreadsheetDocument.WorkbookPart.GetIdOfPart(worksheetPart),
SheetId = 1,
Name = "Sheet1"
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public void Setup()
[Benchmark(Description = "MiniExcel Fill Template")]
public void MiniExcel_Template_Generate_Test()
{
const string templatePath = "TestTemplateBasicIEmumerableFill.xlsx";
const string templatePath = "data/TestTemplateBasicIEmumerableFill.xlsx";

using var path = AutoDeletingPath.Create();
var value = new
Expand All @@ -56,7 +56,7 @@ public void MiniExcel_Template_Generate_Test()
[Benchmark(Description = "ClosedXml.Report Generate Template")]
public void ClosedXml_Report_Template_Generate_Test()
{
const string templatePath = "TestTemplateBasicIEmumerableFill_ClosedXML_Report.xlsx";
const string templatePath = "data/TestTemplateBasicIEmumerableFill_ClosedXML_Report.xlsx";

using var path = AutoDeletingPath.Create();
var value = new
Expand Down Expand Up @@ -97,4 +97,4 @@ public void MiniExcel_Mapping_Template_Generate_Test()

_mappingTemplater.FillTemplate(outputPath.FilePath, templatePath.FilePath, employees);
}
}
}
17 changes: 6 additions & 11 deletions benchmarks/MiniExcel.Benchmarks/MiniExcel.Benchmarks.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,12 @@
</ItemGroup>

<ItemGroup>
<None Update="Test1,000,000x10.xlsx" CopyToOutputDirectory="PreserveNewest" />
<None Update="Test10,000x10.xlsx" CopyToOutputDirectory="PreserveNewest" />
<None Update="Test100,000x10.xlsx" CopyToOutputDirectory="PreserveNewest" />
<None Update="Test10x10.xlsx" CopyToOutputDirectory="PreserveNewest" />
<None Update="Test100x10.xlsx" CopyToOutputDirectory="PreserveNewest" />
<None Update="TestTemplateBasicIEmumerableFill.xlsx" CopyToOutputDirectory="PreserveNewest" />
<None Update="TestTemplateBasicIEmumerableFill_ClosedXML_Report.xlsx" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>

<ItemGroup>
<Folder Include="Properties\" />
<None Update="data\Test10,000x10.xlsx" CopyToOutputDirectory="PreserveNewest" />
<None Update="data\Test100,000x10.xlsx" CopyToOutputDirectory="PreserveNewest" />
<None Update="data\Test10x10.xlsx" CopyToOutputDirectory="PreserveNewest" />
<None Update="data\Test100x10.xlsx" CopyToOutputDirectory="PreserveNewest" />
<None Update="data\TestTemplateBasicIEmumerableFill.xlsx" CopyToOutputDirectory="PreserveNewest" />
<None Update="data\TestTemplateBasicIEmumerableFill_ClosedXML_Report.xlsx" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>

<ItemGroup>
Expand Down
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -220,23 +220,6 @@ public async Task TestDatetimeSpanFormat_ClosedXml()
Assert.Equal(TimeSpan.FromHours(10), (TimeSpan)b);
}

[Fact]
public async Task LargeFileQueryStrongTypeMapping_Test()
{
const string path = "../../../../../benchmarks/MiniExcel.Benchmarks/Test1,000,000x10.xlsx";
await using (var stream = File.OpenRead(path))
{
var rows = await _excelImporter.QueryAsync<DemoPocoHelloWorld>(stream).Take(2).ToListAsync();
Assert.Equal("HelloWorld2", rows[0].HelloWorld1);
Assert.Equal("HelloWorld3", rows[1].HelloWorld1);
}
{
var rows = await _excelImporter.QueryAsync<DemoPocoHelloWorld>(path).Take(2).ToListAsync();
Assert.Equal("HelloWorld2", rows[0].HelloWorld1);
Assert.Equal("HelloWorld3", rows[1].HelloWorld1);
}
}

[Theory]
[InlineData("../../../../data/xlsx/ExcelDataReaderCollections/TestChess.xlsx")]
[InlineData("../../../../data/xlsx/TestCenterEmptyRow/TestCenterEmptyRow.xlsx")]
Expand Down Expand Up @@ -300,32 +283,6 @@ public async Task FixDimensionJustOneColumnParsingError_Test()
Assert.Equal(2, rows.Count);
}

[Fact]
public async Task QueryByLINQExtensionsVoidTaskLargeFileOOMTest()
{
const string path = "../../../../../benchmarks/MiniExcel.Benchmarks/Test1,000,000x10.xlsx";

{
var row = await _excelImporter.QueryAsync(path).FirstAsync();
Assert.Equal("HelloWorld1", row.A);
}

await using (var stream = File.OpenRead(path))
{
var row = await _excelImporter.QueryAsync(stream).Cast<IDictionary<string, object>>().FirstAsync();
Assert.Equal("HelloWorld1", row["A"]);
}

{
var count = await _excelImporter.QueryAsync(path)
.Cast<IDictionary<string, object>>()
.Take(10)
.CountAsync();

Assert.Equal(10, count);
}
}

[Fact]
public async Task QueryByStrongTypeParameterTest()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -382,25 +382,6 @@ public void TestDatetimeSpanFormat_ClosedXml()
Assert.Equal(TimeSpan.FromHours(10), (TimeSpan)b);
}

[Fact]
public void LargeFileQueryStrongTypeMapping_Test()
{
const string path = "../../../../../benchmarks/MiniExcel.Benchmarks/Test1,000,000x10.xlsx";
using (var stream = File.OpenRead(path))
{
var rows = _excelImporter.Query<DemoPocoHelloWorld>(stream).Take(2).ToList();

Assert.Equal("HelloWorld2", rows[0].HelloWorld1);
Assert.Equal("HelloWorld3", rows[1].HelloWorld1);
}
{
var rows = _excelImporter.Query<DemoPocoHelloWorld>(path).Take(2).ToList();

Assert.Equal("HelloWorld2", rows[0].HelloWorld1);
Assert.Equal("HelloWorld3", rows[1].HelloWorld1);
}
}

[Theory]
[InlineData("../../../../data/xlsx/ExcelDataReaderCollections/TestChess.xlsx")]
[InlineData("../../../../data/xlsx/TestCenterEmptyRow/TestCenterEmptyRow.xlsx")]
Expand Down Expand Up @@ -461,24 +442,6 @@ public void FixDimensionJustOneColumnParsingError_Test()
Assert.Equal(2, rows.Count);
}

[Fact]
public void QueryByLINQExtensionsAvoidLargeFileOOMTest()
{
const string path = "../../../../../benchmarks/MiniExcel.Benchmarks/Test1,000,000x10.xlsx";

var query1 = _excelImporter.Query(path).First();
Assert.Equal("HelloWorld1", query1.A);

using (var stream = File.OpenRead(path))
{
var query2 = _excelImporter.Query(stream).First();
Assert.Equal("HelloWorld1", query2.A);
}

var query3 = _excelImporter.Query(path).Take(10);
Assert.Equal(10, query3.Count());
}

[Fact]
public void QueryByStrongTypeParameterTest()
{
Expand Down Expand Up @@ -535,33 +498,6 @@ public void TestStirctOpenXml()
Assert.Equal(rows[1].C, "value3");
}

[Fact]
public void SharedStringCacheTest()
{
const string path = "../../../../../benchmarks/MiniExcel.Benchmarks/Test1,000,000x10_SharingStrings.xlsx";

var ts = Stopwatch.GetTimestamp();
_ = _excelImporter.Query(path, configuration: new OpenXmlConfiguration { EnableSharedStringCache = true }).First();
using var currentProcess = Process.GetCurrentProcess();
var totalBytesOfMemoryUsed = currentProcess.WorkingSet64;

_output.WriteLine("totalBytesOfMemoryUsed: " + totalBytesOfMemoryUsed);
_output.WriteLine("elapsedMilliseconds: " + Stopwatch.GetElapsedTime(ts).TotalMilliseconds);
}

[Fact]
public void SharedStringNoCacheTest()
{
const string path = "../../../../../benchmarks/MiniExcel.Benchmarks/Test1,000,000x10_SharingStrings.xlsx";

var ts = Stopwatch.GetTimestamp();
_ = _excelImporter.Query(path).First();
using var currentProcess = Process.GetCurrentProcess();
var totalBytesOfMemoryUsed = currentProcess.WorkingSet64;
_output.WriteLine("totalBytesOfMemoryUsed: " + totalBytesOfMemoryUsed);
_output.WriteLine("elapsedMilliseconds: " + Stopwatch.GetElapsedTime(ts).TotalMilliseconds);
}

[Fact]
public void DateOnlySupportTest()
{
Expand Down
5 changes: 0 additions & 5 deletions tests/MiniExcel.OpenXml.Tests/Main/Models.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@ internal class Demo
public decimal Column2 { get; set; }
}

internal class DemoPocoHelloWorld
{
public string? HelloWorld1 { get; set; }
}

internal class ExcelUriDemo
{
public string? Name { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.0.1" />

<PackageReference Include="System.Security.Cryptography.Xml" Version="8.0.3" />
<PackageReference Include="xunit" Version="2.9.3" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.5">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
Loading