Skip to content

Commit df69ad4

Browse files
Added summary to the MiniExcel facade class
The remarks explain the purpose of the class and advise the consumers of the library to favor the usage of the new `MiniExcelV2` class instead for a better user experience.
1 parent fe0ba00 commit df69ad4

1 file changed

Lines changed: 20 additions & 13 deletions

File tree

‎src/MiniExcel/MiniExcel.cs‎

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,19 @@
55
using MiniExcelLib.OpenXml.Models;
66
using MiniExcelLib.OpenXml.Picture;
77
using Zomp.SyncMethodGenerator;
8+
89
using NewOpenXmlConfiguration = MiniExcelLib.OpenXml.OpenXmlConfiguration;
10+
using NewCsvConfiguration = MiniExcelLib.Csv.CsvConfiguration;
911
using MiniExcelDataReader = MiniExcelLib.Core.MiniExcelDataReaderBase;
1012

1113
// ReSharper disable once CheckNamespace
1214
namespace MiniExcelLibs;
1315

16+
/// <summary>
17+
/// This class is a facade containing the methods' signatures from the V1 API, preserved for backwards compatibility.
18+
/// We encourage the users to take advantage of the idiomatic <see cref="MiniExcelV2"/> class instead
19+
/// for a compartimentalized, richer and more flexible API.
20+
/// </summary>
1421
public static partial class MiniExcel
1522
{
1623
private static readonly OpenXmlExporter ExcelExporter = MiniExcelV2.Exporters.GetOpenXmlExporter();
@@ -60,7 +67,7 @@ public static async Task<int> InsertAsync(string path, object value, string shee
6067
return type switch
6168
{
6269
ExcelType.XLSX => await ExcelExporter.InsertSheetAsync(path, value, sheetName, printHeader, overwriteSheet, configuration as NewOpenXmlConfiguration, progress, cancellationToken).ConfigureAwait(false),
63-
ExcelType.CSV => await CsvExporter.AppendAsync(path, value, printHeader, configuration as Csv.CsvConfiguration, progress, cancellationToken).ConfigureAwait(false),
70+
ExcelType.CSV => await CsvExporter.AppendAsync(path, value, printHeader, configuration as NewCsvConfiguration, progress, cancellationToken).ConfigureAwait(false),
6471
_ => throw new InvalidDataException($"Type {type} is not a valid Excel type")
6572
};
6673
}
@@ -74,7 +81,7 @@ public static async Task<int> InsertAsync(this Stream stream, object value, stri
7481
return type switch
7582
{
7683
ExcelType.XLSX => await ExcelExporter.InsertSheetAsync(stream, value, sheetName, printHeader, overwriteSheet, configuration as NewOpenXmlConfiguration, progress, cancellationToken).ConfigureAwait(false),
77-
ExcelType.CSV => await CsvExporter.AppendAsync(stream, value, configuration as Csv.CsvConfiguration, progress, cancellationToken).ConfigureAwait(false),
84+
ExcelType.CSV => await CsvExporter.AppendAsync(stream, value, configuration as NewCsvConfiguration, progress, cancellationToken).ConfigureAwait(false),
7885
_ => throw new InvalidDataException($"Type {type} is not a valid Excel type")
7986
};
8087
}
@@ -88,7 +95,7 @@ public static async Task<int[]> SaveAsAsync(string path, object value, bool prin
8895
return type switch
8996
{
9097
ExcelType.XLSX => await ExcelExporter.ExportAsync(path, value, printHeader, sheetName, overwriteFile, configuration as NewOpenXmlConfiguration, progress, cancellationToken).ConfigureAwait(false),
91-
ExcelType.CSV => [await CsvExporter.ExportAsync(path, value, printHeader, overwriteFile, configuration as Csv.CsvConfiguration, progress, cancellationToken).ConfigureAwait(false)],
98+
ExcelType.CSV => [await CsvExporter.ExportAsync(path, value, printHeader, overwriteFile, configuration as NewCsvConfiguration, progress, cancellationToken).ConfigureAwait(false)],
9299
_ => throw new InvalidDataException($"Type {type} is not a valid Excel type")
93100
};
94101
}
@@ -102,7 +109,7 @@ public static async Task<int[]> SaveAsAsync(this Stream stream, object value, bo
102109
return type switch
103110
{
104111
ExcelType.XLSX => await ExcelExporter.ExportAsync(stream, value, printHeader, sheetName, configuration as NewOpenXmlConfiguration, progress, cancellationToken).ConfigureAwait(false),
105-
ExcelType.CSV => [await CsvExporter.ExportAsync(stream, value, printHeader, configuration as Csv.CsvConfiguration, progress, cancellationToken).ConfigureAwait(false)],
112+
ExcelType.CSV => [await CsvExporter.ExportAsync(stream, value, printHeader, configuration as NewCsvConfiguration, progress, cancellationToken).ConfigureAwait(false)],
106113
_ => throw new InvalidDataException($"Type {type} is not a valid Excel type")
107114
};
108115
}
@@ -117,7 +124,7 @@ public static async Task<int[]> SaveAsAsync(this Stream stream, object value, bo
117124
return type switch
118125
{
119126
ExcelType.XLSX => ExcelImporter.QueryAsync<T>(path, sheetName, startCell, !hasHeader, configuration as NewOpenXmlConfiguration, cancellationToken),
120-
ExcelType.CSV => CsvImporter.QueryAsync<T>(path, !hasHeader, configuration as Csv.CsvConfiguration, cancellationToken),
127+
ExcelType.CSV => CsvImporter.QueryAsync<T>(path, !hasHeader, configuration as NewCsvConfiguration, cancellationToken),
121128
_ => throw new InvalidDataException($"Type {type} is not a valid Excel type")
122129
};
123130
}
@@ -132,7 +139,7 @@ public static async Task<int[]> SaveAsAsync(this Stream stream, object value, bo
132139
return type switch
133140
{
134141
ExcelType.XLSX => ExcelImporter.QueryAsync<T>(stream, sheetName, startCell, !hasHeader, configuration as NewOpenXmlConfiguration, leaveOpen: true, cancellationToken),
135-
ExcelType.CSV => CsvImporter.QueryAsync<T>(stream, !hasHeader, configuration as Csv.CsvConfiguration, leaveOpen: true, cancellationToken),
142+
ExcelType.CSV => CsvImporter.QueryAsync<T>(stream, !hasHeader, configuration as NewCsvConfiguration, leaveOpen: true, cancellationToken),
136143
_ => throw new InvalidDataException($"Type {type} is not a valid Excel type")
137144
};
138145
}
@@ -144,7 +151,7 @@ public static IAsyncEnumerable<dynamic> QueryAsync(string path, bool useHeaderRo
144151
return type switch
145152
{
146153
ExcelType.XLSX => ExcelImporter.QueryAsync(path, useHeaderRow, sheetName, startCell, configuration as NewOpenXmlConfiguration, cancellationToken),
147-
ExcelType.CSV => CsvImporter.QueryAsync(path, useHeaderRow, configuration as Csv.CsvConfiguration, cancellationToken),
154+
ExcelType.CSV => CsvImporter.QueryAsync(path, useHeaderRow, configuration as NewCsvConfiguration, cancellationToken),
148155
_ => throw new InvalidDataException($"Type {type} is not a valid Excel type")
149156
};
150157
}
@@ -156,7 +163,7 @@ public static IAsyncEnumerable<dynamic> QueryAsync(this Stream stream, bool useH
156163
return type switch
157164
{
158165
ExcelType.XLSX => ExcelImporter.QueryAsync(stream, useHeaderRow, sheetName, startCell, configuration as NewOpenXmlConfiguration, leaveOpen: true, cancellationToken),
159-
ExcelType.CSV => CsvImporter.QueryAsync(stream, useHeaderRow, configuration as Csv.CsvConfiguration,leaveOpen: true, cancellationToken),
166+
ExcelType.CSV => CsvImporter.QueryAsync(stream, useHeaderRow, configuration as NewCsvConfiguration,leaveOpen: true, cancellationToken),
160167
_ => throw new InvalidDataException($"Type {type} is not a valid Excel type")
161168
};
162169
}
@@ -189,7 +196,7 @@ public static IAsyncEnumerable<dynamic> QueryRangeAsync(this Stream stream, bool
189196
return type switch
190197
{
191198
ExcelType.XLSX => ExcelImporter.QueryRangeAsync(stream, useHeaderRow, sheetName, startCell, endCell, configuration as NewOpenXmlConfiguration, leaveOpen: true, cancellationToken),
192-
ExcelType.CSV => CsvImporter.QueryAsync(stream, useHeaderRow, configuration as Csv.CsvConfiguration, leaveOpen: true, cancellationToken),
199+
ExcelType.CSV => CsvImporter.QueryAsync(stream, useHeaderRow, configuration as NewCsvConfiguration, leaveOpen: true, cancellationToken),
193200
_ => throw new InvalidDataException($"Type {type} is not a valid Excel type")
194201
};
195202
}
@@ -283,7 +290,7 @@ public static async Task<DataTable> QueryAsDataTableAsync(string path, bool useH
283290
return type switch
284291
{
285292
ExcelType.XLSX => await ExcelImporter.QueryAsDataTableAsync(path, useHeaderRow, sheetName, startCell, configuration as NewOpenXmlConfiguration, cancellationToken).ConfigureAwait(false),
286-
ExcelType.CSV => await CsvImporter.QueryAsDataTableAsync(path, useHeaderRow, configuration as Csv.CsvConfiguration, cancellationToken).ConfigureAwait(false),
293+
ExcelType.CSV => await CsvImporter.QueryAsDataTableAsync(path, useHeaderRow, configuration as NewCsvConfiguration, cancellationToken).ConfigureAwait(false),
287294
_ => throw new InvalidDataException($"Type {type} is not a valid Excel type")
288295
};
289296
}
@@ -296,7 +303,7 @@ public static async Task<DataTable> QueryAsDataTableAsync(this Stream stream, bo
296303
return type switch
297304
{
298305
ExcelType.XLSX => await ExcelImporter.QueryAsDataTableAsync(stream, useHeaderRow, sheetName, startCell, configuration as NewOpenXmlConfiguration, leaveOpen: true, cancellationToken).ConfigureAwait(false),
299-
ExcelType.CSV => await CsvImporter.QueryAsDataTableAsync(stream, useHeaderRow, configuration as Csv.CsvConfiguration, leaveOpen: true, cancellationToken).ConfigureAwait(false),
306+
ExcelType.CSV => await CsvImporter.QueryAsDataTableAsync(stream, useHeaderRow, configuration as NewCsvConfiguration, leaveOpen: true, cancellationToken).ConfigureAwait(false),
300307
_ => throw new InvalidDataException($"Excel type {type} is not a valid Excel type")
301308
};
302309
}
@@ -324,7 +331,7 @@ public static async Task<ICollection<string>> GetColumnsAsync(string path, bool
324331
return type switch
325332
{
326333
ExcelType.XLSX => await ExcelImporter.GetColumnNamesAsync(path, useHeaderRow, sheetName, startCell, cancellationToken).ConfigureAwait(false),
327-
ExcelType.CSV => await CsvImporter.GetColumnNamesAsync(path, useHeaderRow, configuration as Csv.CsvConfiguration, cancellationToken).ConfigureAwait(false),
334+
ExcelType.CSV => await CsvImporter.GetColumnNamesAsync(path, useHeaderRow, configuration as NewCsvConfiguration, cancellationToken).ConfigureAwait(false),
328335
_ => throw new InvalidDataException($"Excel type {type} is not a valid Excel type")
329336
};
330337
}
@@ -336,7 +343,7 @@ public static async Task<ICollection<string>> GetColumnsAsync(this Stream stream
336343
return type switch
337344
{
338345
ExcelType.XLSX => await ExcelImporter.GetColumnNamesAsync(stream, useHeaderRow, sheetName, startCell, leaveOpen: true, cancellationToken).ConfigureAwait(false),
339-
ExcelType.CSV => await CsvImporter.GetColumnNamesAsync(stream, useHeaderRow, configuration as Csv.CsvConfiguration, leaveOpen: true, cancellationToken).ConfigureAwait(false),
346+
ExcelType.CSV => await CsvImporter.GetColumnNamesAsync(stream, useHeaderRow, configuration as NewCsvConfiguration, leaveOpen: true, cancellationToken).ConfigureAwait(false),
340347
_ => throw new InvalidDataException($"Excel type {type} is not a valid Excel type")
341348
};
342349
}

0 commit comments

Comments
 (0)