-
-
Notifications
You must be signed in to change notification settings - Fork 193
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7bff365
commit 73954e0
Showing
49 changed files
with
1,690 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?xml version = "1.0" encoding = "UTF-8" ?> | ||
<Application xmlns="http://schemas.microsoft.com/dotnet/2021/maui" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
xmlns:local="clr-namespace:MauiExcel" | ||
x:Class="MauiExcel.App"> | ||
<Application.Resources> | ||
<ResourceDictionary> | ||
<ResourceDictionary.MergedDictionaries> | ||
<ResourceDictionary Source="Resources/Styles/Colors.xaml" /> | ||
<ResourceDictionary Source="Resources/Styles/Styles.xaml" /> | ||
</ResourceDictionary.MergedDictionaries> | ||
</ResourceDictionary> | ||
</Application.Resources> | ||
</Application> |
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,14 @@ | ||
namespace MauiExcel; | ||
|
||
public partial class App : Application | ||
{ | ||
public App() | ||
{ | ||
InitializeComponent(); | ||
} | ||
|
||
protected override Window CreateWindow(IActivationState? activationState) | ||
{ | ||
return new Window(new AppShell()); | ||
} | ||
} |
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,15 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<Shell | ||
x:Class="MauiExcel.AppShell" | ||
xmlns="http://schemas.microsoft.com/dotnet/2021/maui" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
xmlns:local="clr-namespace:MauiExcel" | ||
Shell.FlyoutBehavior="Flyout" | ||
Title="MauiExcel"> | ||
|
||
<ShellContent | ||
Title="Home" | ||
ContentTemplate="{DataTemplate local:MainPage}" | ||
Route="MainPage" /> | ||
|
||
</Shell> |
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,9 @@ | ||
namespace MauiExcel; | ||
|
||
public partial class AppShell : Shell | ||
{ | ||
public AppShell() | ||
{ | ||
InitializeComponent(); | ||
} | ||
} |
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,57 @@ | ||
using BenchmarkDotNet.Attributes; | ||
using MauiExcel.Services; | ||
|
||
namespace MauiExcel; | ||
|
||
[MemoryDiagnoser] | ||
public class ExcelBenchmark | ||
{ | ||
[Params(10, 1000)] | ||
public int N; | ||
|
||
public List<List<string>> Data = []; | ||
|
||
[GlobalSetup] | ||
public void GlobalSetup() | ||
{ | ||
Data = []; | ||
for (var i = 0; i < N; i++) | ||
{ | ||
var rows = new List<string>(); | ||
for (var j = 0; j < N; j++) | ||
{ | ||
rows.Add($"Item-{i}-{j}"); | ||
} | ||
|
||
Data.Add(rows); | ||
} | ||
} | ||
|
||
[Benchmark] | ||
public void RunOpenXmlService() | ||
{ | ||
using var stream = new FileStream(Path.GetRandomFileName(), FileMode.Create); | ||
OpenXmlService.Save(stream, Data); | ||
} | ||
|
||
[Benchmark] | ||
public void RunClosedXmlService() | ||
{ | ||
var stream = new FileStream(Path.GetRandomFileName(), FileMode.Create); | ||
ClosedXmlService.Save(stream, Data); | ||
} | ||
|
||
[Benchmark(Baseline = true)] | ||
public void RunCustomExcelService() | ||
{ | ||
var stream = new FileStream(Path.GetRandomFileName(), FileMode.Create); | ||
CustomExcelService.Save(stream, Data); | ||
} | ||
|
||
[Benchmark] | ||
public void RunMiniExcelService() | ||
{ | ||
var stream = new FileStream(Path.GetRandomFileName(), FileMode.Create); | ||
MiniExcelService.Save(stream, Data); | ||
} | ||
} |
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,65 @@ | ||
using BenchmarkDotNet.Attributes; | ||
using MauiExcel.Services; | ||
|
||
namespace MauiExcel; | ||
|
||
[MemoryDiagnoser] | ||
public class ExcelBenchmarkType | ||
{ | ||
[Params(100, 1000, 10000)] | ||
public int N; | ||
|
||
public List<Data> Data = []; | ||
|
||
[GlobalSetup] | ||
public void GlobalSetup() | ||
{ | ||
Data = []; | ||
for (var i = 0; i < N; i++) | ||
{ | ||
var data = new Data | ||
{ | ||
Column1 = $"Item-{i}-1", | ||
Column2 = $"Item-{i}-2", | ||
Column3 = $"Item-{i}-3", | ||
Column4 = $"Item-{i}-4", | ||
Column5 = $"Item-{i}-5", | ||
Column6 = $"Item-{i}-6", | ||
Column7 = $"Item-{i}-7", | ||
Column8 = $"Item-{i}-8", | ||
Column9 = $"Item-{i}-9", | ||
Column10 = $"Item-{i}-10" | ||
}; | ||
|
||
Data.Add(data); | ||
} | ||
} | ||
|
||
[Benchmark] | ||
public void RunOpenXmlService() | ||
{ | ||
using var stream = new FileStream(Path.GetRandomFileName(), FileMode.Create); | ||
OpenXmlService.Save(stream, Data); | ||
} | ||
|
||
[Benchmark] | ||
public void RunClosedXmlService() | ||
{ | ||
using var stream = new FileStream(Path.GetRandomFileName(), FileMode.Create); | ||
ClosedXmlService.Save(stream, Data); | ||
} | ||
|
||
[Benchmark(Baseline = true)] | ||
public void RunCustomExcelService() | ||
{ | ||
using var stream = new FileStream(Path.GetRandomFileName(), FileMode.Create); | ||
CustomExcelService.Save(stream, Data); | ||
} | ||
|
||
[Benchmark] | ||
public void RunMiniExcelService() | ||
{ | ||
using var stream = new FileStream(Path.GetRandomFileName(), FileMode.Create); | ||
MiniExcelService.Save(stream, Data); | ||
} | ||
} |
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,77 @@ | ||
using BenchmarkDotNet.Attributes; | ||
using MauiExcel.Services; | ||
|
||
namespace MauiExcel; | ||
|
||
[MemoryDiagnoser] | ||
[IterationCount(5)] | ||
public class ExcelBenchmarkTypeLarge | ||
{ | ||
public List<Data> DataType = []; | ||
|
||
public List<List<string>> Data = []; | ||
|
||
[GlobalSetup] | ||
public void GlobalSetup() | ||
{ | ||
Data = []; | ||
for (var i = 0; i < 10_000; i++) | ||
{ | ||
var rows = new List<string>(); | ||
for (var j = 0; j < 10_000; j++) | ||
{ | ||
rows.Add($"Item-{i}-{j}"); | ||
} | ||
|
||
Data.Add(rows); | ||
} | ||
|
||
DataType = []; | ||
for (var i = 0; i < 1_000_000; i++) | ||
{ | ||
var data = new Data | ||
{ | ||
Column1 = $"Item-{i}-1", | ||
Column2 = $"Item-{i}-2", | ||
Column3 = $"Item-{i}-3", | ||
Column4 = $"Item-{i}-4", | ||
Column5 = $"Item-{i}-5", | ||
Column6 = $"Item-{i}-6", | ||
Column7 = $"Item-{i}-7", | ||
Column8 = $"Item-{i}-8", | ||
Column9 = $"Item-{i}-9", | ||
Column10 = $"Item-{i}-10" | ||
}; | ||
|
||
DataType.Add(data); | ||
} | ||
} | ||
|
||
[Benchmark] | ||
public void RunCustomExcelService() | ||
{ | ||
using var stream = new FileStream(Path.GetRandomFileName(), FileMode.Create); | ||
CustomExcelService.Save(stream, Data); | ||
} | ||
|
||
[Benchmark] | ||
public void RunMiniExcelService() | ||
{ | ||
using var stream = new FileStream(Path.GetRandomFileName(), FileMode.Create); | ||
MiniExcelService.Save(stream, Data); | ||
} | ||
|
||
[Benchmark] | ||
public void RunCustomExcelServiceType() | ||
{ | ||
using var stream = new FileStream(Path.GetRandomFileName(), FileMode.Create); | ||
CustomExcelService.Save(stream, DataType); | ||
} | ||
|
||
[Benchmark] | ||
public void RunMiniExcelServiceType() | ||
{ | ||
using var stream = new FileStream(Path.GetRandomFileName(), FileMode.Create); | ||
MiniExcelService.Save(stream, DataType); | ||
} | ||
} |
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,15 @@ | ||
namespace MauiExcel; | ||
|
||
public class Data | ||
{ | ||
public string? Column1 { get; set; } | ||
public string? Column2 { get; set; } | ||
public string? Column3 { get; set; } | ||
public string? Column4 { get; set; } | ||
public string? Column5 { get; set; } | ||
public string? Column6 { get; set; } | ||
public string? Column7 { get; set; } | ||
public string? Column8 { get; set; } | ||
public string? Column9 { get; set; } | ||
public string? Column10 { get; set; } | ||
} |
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,17 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
x:Class="MauiExcel.MainPage"> | ||
|
||
<ScrollView> | ||
<VerticalStackLayout | ||
Padding="30,0" | ||
Spacing="25"> | ||
<Button | ||
Text="Click me" | ||
Clicked="OnExportClicked" | ||
HorizontalOptions="Fill" /> | ||
</VerticalStackLayout> | ||
</ScrollView> | ||
|
||
</ContentPage> |
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,73 @@ | ||
namespace MauiExcel; | ||
|
||
using Services; | ||
|
||
public partial class MainPage : ContentPage | ||
{ | ||
public MainPage() | ||
{ | ||
InitializeComponent(); | ||
} | ||
|
||
private void OnExportClicked(object sender, EventArgs e) | ||
{ | ||
var data = new List<List<string>>(); | ||
|
||
for (var i = 0; i < 10; i++) | ||
{ | ||
var rows = new List<string>(); | ||
for (var j = 0; j < 10; j++) | ||
{ | ||
rows.Add($"Item-{i}-{j}"); | ||
} | ||
|
||
data.Add(rows); | ||
} | ||
|
||
using var closedXmlFileStream = new FileStream("closedXml.xlsx", FileMode.Create); | ||
ClosedXmlService.Save(closedXmlFileStream, data); | ||
|
||
using var customExcelFileStream = new FileStream("customExcel.xlsx", FileMode.Create); | ||
CustomExcelService.Save(customExcelFileStream, data); | ||
|
||
using var openExcelFileStream = new FileStream("openXml.xlsx", FileMode.Create); | ||
OpenXmlService.Save(openExcelFileStream, data); | ||
|
||
using var miniExcelFileStream = new FileStream("miniExcel.xlsx", FileMode.Create); | ||
MiniExcelService.Save(miniExcelFileStream, data); | ||
|
||
var data2 = new List<Data>(); | ||
|
||
for (var i = 0; i < 10; i++) | ||
{ | ||
var item = new Data | ||
{ | ||
Column1 = $"Item-{i}-1", | ||
Column2 = $"Item-{i}-2", | ||
Column3 = $"Item-{i}-3", | ||
Column4 = $"Item-{i}-4", | ||
Column5 = $"Item-{i}-5", | ||
Column6 = $"Item-{i}-6", | ||
Column7 = $"Item-{i}-7", | ||
Column8 = $"Item-{i}-8", | ||
Column9 = $"Item-{i}-9", | ||
Column10 = $"Item-{i}-10" | ||
}; | ||
|
||
data2.Add(item); | ||
} | ||
|
||
using var closedXmlFileStream2 = new FileStream("closedXml2.xlsx", FileMode.Create); | ||
ClosedXmlService.Save(closedXmlFileStream2, data2); | ||
|
||
using var customExcelFileStream2 = new FileStream("customExcel2.xlsx", FileMode.Create); | ||
CustomExcelService.Save(customExcelFileStream2, data2); | ||
|
||
using var openExcelFileStream2 = new FileStream("openXml2.xlsx", FileMode.Create); | ||
OpenXmlService.Save(openExcelFileStream2, data2); | ||
|
||
using var miniExcelFileStream2 = new FileStream("miniExcel2.xlsx", FileMode.Create); | ||
MiniExcelService.Save(miniExcelFileStream2, data2); | ||
} | ||
} | ||
|
Oops, something went wrong.