From 73954e0848e272d682787e94a6420e64cceb8785 Mon Sep 17 00:00:00 2001 From: Vladislav Antonyuk Date: Mon, 30 Dec 2024 20:49:50 +0200 Subject: [PATCH] MauiExcel --- MauiExcel/App.xaml | 14 + MauiExcel/App.xaml.cs | 14 + MauiExcel/AppShell.xaml | 15 + MauiExcel/AppShell.xaml.cs | 9 + MauiExcel/Benchmarks/ExcelBenchmark.cs | 57 +++ MauiExcel/Benchmarks/ExcelBenchmarkType.cs | 65 +++ .../Benchmarks/ExcelBenchmarkTypeLarge.cs | 77 +++ MauiExcel/Data.cs | 15 + MauiExcel/MainPage.xaml | 17 + MauiExcel/MainPage.xaml.cs | 73 +++ MauiExcel/MauiExcel.csproj | 33 ++ MauiExcel/MauiExcelBenchmark.csproj | 15 + MauiExcel/MauiProgram.cs | 14 + .../Platforms/Android/AndroidManifest.xml | 6 + MauiExcel/Platforms/Android/MainActivity.cs | 10 + .../Platforms/Android/MainApplication.cs | 15 + .../Android/Resources/values/colors.xml | 6 + .../Platforms/MacCatalyst/AppDelegate.cs | 9 + .../Platforms/MacCatalyst/Entitlements.plist | 14 + MauiExcel/Platforms/MacCatalyst/Info.plist | 38 ++ MauiExcel/Platforms/MacCatalyst/Program.cs | 15 + MauiExcel/Platforms/Tizen/Main.cs | 16 + MauiExcel/Platforms/Tizen/tizen-manifest.xml | 15 + MauiExcel/Platforms/Windows/App.xaml | 8 + MauiExcel/Platforms/Windows/App.xaml.cs | 24 + .../Platforms/Windows/Package.appxmanifest | 46 ++ MauiExcel/Platforms/Windows/app.manifest | 15 + MauiExcel/Platforms/iOS/AppDelegate.cs | 9 + MauiExcel/Platforms/iOS/Info.plist | 32 ++ MauiExcel/Platforms/iOS/Program.cs | 15 + .../iOS/Resources/PrivacyInfo.xcprivacy | 51 ++ MauiExcel/Program.cs | 5 + MauiExcel/Properties/launchSettings.json | 8 + MauiExcel/README.md | 7 + MauiExcel/README.mdpp | 7 + MauiExcel/Resources/AppIcon/appicon.svg | 4 + MauiExcel/Resources/AppIcon/appiconfg.svg | 8 + MauiExcel/Resources/Images/dotnet_bot.png | Bin 0 -> 93437 bytes MauiExcel/Resources/Raw/AboutAssets.txt | 15 + MauiExcel/Resources/Splash/splash.svg | 8 + MauiExcel/Resources/Styles/Colors.xaml | 45 ++ MauiExcel/Resources/Styles/Styles.xaml | 451 ++++++++++++++++++ MauiExcel/Services/ClosedXmlExcelService.cs | 48 ++ MauiExcel/Services/CustomExcelService.cs | 154 ++++++ MauiExcel/Services/MiniExcelService.cs | 86 ++++ MauiExcel/Services/OpenXmlService.cs | 74 +++ MauiSamples.slnx | 4 + README.md | 2 + README.mdpp | 2 + 49 files changed, 1690 insertions(+) create mode 100644 MauiExcel/App.xaml create mode 100644 MauiExcel/App.xaml.cs create mode 100644 MauiExcel/AppShell.xaml create mode 100644 MauiExcel/AppShell.xaml.cs create mode 100644 MauiExcel/Benchmarks/ExcelBenchmark.cs create mode 100644 MauiExcel/Benchmarks/ExcelBenchmarkType.cs create mode 100644 MauiExcel/Benchmarks/ExcelBenchmarkTypeLarge.cs create mode 100644 MauiExcel/Data.cs create mode 100644 MauiExcel/MainPage.xaml create mode 100644 MauiExcel/MainPage.xaml.cs create mode 100644 MauiExcel/MauiExcel.csproj create mode 100644 MauiExcel/MauiExcelBenchmark.csproj create mode 100644 MauiExcel/MauiProgram.cs create mode 100644 MauiExcel/Platforms/Android/AndroidManifest.xml create mode 100644 MauiExcel/Platforms/Android/MainActivity.cs create mode 100644 MauiExcel/Platforms/Android/MainApplication.cs create mode 100644 MauiExcel/Platforms/Android/Resources/values/colors.xml create mode 100644 MauiExcel/Platforms/MacCatalyst/AppDelegate.cs create mode 100644 MauiExcel/Platforms/MacCatalyst/Entitlements.plist create mode 100644 MauiExcel/Platforms/MacCatalyst/Info.plist create mode 100644 MauiExcel/Platforms/MacCatalyst/Program.cs create mode 100644 MauiExcel/Platforms/Tizen/Main.cs create mode 100644 MauiExcel/Platforms/Tizen/tizen-manifest.xml create mode 100644 MauiExcel/Platforms/Windows/App.xaml create mode 100644 MauiExcel/Platforms/Windows/App.xaml.cs create mode 100644 MauiExcel/Platforms/Windows/Package.appxmanifest create mode 100644 MauiExcel/Platforms/Windows/app.manifest create mode 100644 MauiExcel/Platforms/iOS/AppDelegate.cs create mode 100644 MauiExcel/Platforms/iOS/Info.plist create mode 100644 MauiExcel/Platforms/iOS/Program.cs create mode 100644 MauiExcel/Platforms/iOS/Resources/PrivacyInfo.xcprivacy create mode 100644 MauiExcel/Program.cs create mode 100644 MauiExcel/Properties/launchSettings.json create mode 100644 MauiExcel/README.md create mode 100644 MauiExcel/README.mdpp create mode 100644 MauiExcel/Resources/AppIcon/appicon.svg create mode 100644 MauiExcel/Resources/AppIcon/appiconfg.svg create mode 100644 MauiExcel/Resources/Images/dotnet_bot.png create mode 100644 MauiExcel/Resources/Raw/AboutAssets.txt create mode 100644 MauiExcel/Resources/Splash/splash.svg create mode 100644 MauiExcel/Resources/Styles/Colors.xaml create mode 100644 MauiExcel/Resources/Styles/Styles.xaml create mode 100644 MauiExcel/Services/ClosedXmlExcelService.cs create mode 100644 MauiExcel/Services/CustomExcelService.cs create mode 100644 MauiExcel/Services/MiniExcelService.cs create mode 100644 MauiExcel/Services/OpenXmlService.cs diff --git a/MauiExcel/App.xaml b/MauiExcel/App.xaml new file mode 100644 index 00000000..4ee4b367 --- /dev/null +++ b/MauiExcel/App.xaml @@ -0,0 +1,14 @@ + + + + + + + + + + + diff --git a/MauiExcel/App.xaml.cs b/MauiExcel/App.xaml.cs new file mode 100644 index 00000000..7cdb6687 --- /dev/null +++ b/MauiExcel/App.xaml.cs @@ -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()); + } +} \ No newline at end of file diff --git a/MauiExcel/AppShell.xaml b/MauiExcel/AppShell.xaml new file mode 100644 index 00000000..99ac19a2 --- /dev/null +++ b/MauiExcel/AppShell.xaml @@ -0,0 +1,15 @@ + + + + + + diff --git a/MauiExcel/AppShell.xaml.cs b/MauiExcel/AppShell.xaml.cs new file mode 100644 index 00000000..a3ec626f --- /dev/null +++ b/MauiExcel/AppShell.xaml.cs @@ -0,0 +1,9 @@ +namespace MauiExcel; + +public partial class AppShell : Shell +{ + public AppShell() + { + InitializeComponent(); + } +} diff --git a/MauiExcel/Benchmarks/ExcelBenchmark.cs b/MauiExcel/Benchmarks/ExcelBenchmark.cs new file mode 100644 index 00000000..e59ccb65 --- /dev/null +++ b/MauiExcel/Benchmarks/ExcelBenchmark.cs @@ -0,0 +1,57 @@ +using BenchmarkDotNet.Attributes; +using MauiExcel.Services; + +namespace MauiExcel; + +[MemoryDiagnoser] +public class ExcelBenchmark +{ + [Params(10, 1000)] + public int N; + + public List> Data = []; + + [GlobalSetup] + public void GlobalSetup() + { + Data = []; + for (var i = 0; i < N; i++) + { + var rows = new List(); + 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); + } +} \ No newline at end of file diff --git a/MauiExcel/Benchmarks/ExcelBenchmarkType.cs b/MauiExcel/Benchmarks/ExcelBenchmarkType.cs new file mode 100644 index 00000000..3cbb35c4 --- /dev/null +++ b/MauiExcel/Benchmarks/ExcelBenchmarkType.cs @@ -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 = []; + + [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); + } +} \ No newline at end of file diff --git a/MauiExcel/Benchmarks/ExcelBenchmarkTypeLarge.cs b/MauiExcel/Benchmarks/ExcelBenchmarkTypeLarge.cs new file mode 100644 index 00000000..8a32ccc2 --- /dev/null +++ b/MauiExcel/Benchmarks/ExcelBenchmarkTypeLarge.cs @@ -0,0 +1,77 @@ +using BenchmarkDotNet.Attributes; +using MauiExcel.Services; + +namespace MauiExcel; + +[MemoryDiagnoser] +[IterationCount(5)] +public class ExcelBenchmarkTypeLarge +{ + public List DataType = []; + + public List> Data = []; + + [GlobalSetup] + public void GlobalSetup() + { + Data = []; + for (var i = 0; i < 10_000; i++) + { + var rows = new List(); + 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); + } +} \ No newline at end of file diff --git a/MauiExcel/Data.cs b/MauiExcel/Data.cs new file mode 100644 index 00000000..c389b296 --- /dev/null +++ b/MauiExcel/Data.cs @@ -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; } +} \ No newline at end of file diff --git a/MauiExcel/MainPage.xaml b/MauiExcel/MainPage.xaml new file mode 100644 index 00000000..eb68e046 --- /dev/null +++ b/MauiExcel/MainPage.xaml @@ -0,0 +1,17 @@ + + + + + +