diff --git a/src/MiniExcel/Csv/CsvWriter.cs b/src/MiniExcel/Csv/CsvWriter.cs index ea51edb3..d65daa5e 100644 --- a/src/MiniExcel/Csv/CsvWriter.cs +++ b/src/MiniExcel/Csv/CsvWriter.cs @@ -13,20 +13,18 @@ namespace MiniExcelLibs.Csv { internal class CsvWriter : IExcelWriter, IDisposable { - private readonly Stream _stream; + private readonly StreamWriter _writer; private readonly CsvConfiguration _configuration; private readonly bool _printHeader; - private object _value; - private readonly StreamWriter _writer; + private readonly object _value; private bool _disposedValue; public CsvWriter(Stream stream, object value, IConfiguration configuration, bool printHeader) { - _stream = stream; _configuration = configuration == null ? CsvConfiguration.DefaultConfiguration : (CsvConfiguration)configuration; _printHeader = printHeader; _value = value; - _writer = _configuration.StreamWriterFunc(_stream); + _writer = _configuration.StreamWriterFunc(stream); } public int[] SaveAs() diff --git a/src/MiniExcel/ExcelFactory.cs b/src/MiniExcel/ExcelFactory.cs index b9a64711..36760508 100644 --- a/src/MiniExcel/ExcelFactory.cs +++ b/src/MiniExcel/ExcelFactory.cs @@ -17,7 +17,7 @@ internal static IExcelReader GetProvider(Stream stream, ExcelType excelType, ICo case ExcelType.XLSX: return new ExcelOpenXmlSheetReader(stream, configuration); default: - throw new NotSupportedException("Please Issue for me"); + throw new NotSupportedException("Something went wrong. Please report this issue you are experiencing with MiniExcel."); } } } @@ -55,7 +55,7 @@ internal static IExcelTemplateAsync GetProvider(Stream stream, IConfiguration co var valueExtractor = new InputValueExtractor(); return new ExcelOpenXmlTemplate(stream, configuration, valueExtractor); default: - throw new NotSupportedException("Please Issue for me"); + throw new NotSupportedException("Something went wrong. Please report this issue you are experiencing with MiniExcel."); } } } diff --git a/src/MiniExcel/OpenXml/ExcelOpenXmlSheetWriter.Async.cs b/src/MiniExcel/OpenXml/ExcelOpenXmlSheetWriter.Async.cs index eda438a1..cff0929c 100644 --- a/src/MiniExcel/OpenXml/ExcelOpenXmlSheetWriter.Async.cs +++ b/src/MiniExcel/OpenXml/ExcelOpenXmlSheetWriter.Async.cs @@ -527,11 +527,14 @@ private async Task InsertContentTypesXmlAsync(CancellationToken cancellationToke await GenerateContentTypesXmlAsync(cancellationToken); return; } - +#if NET5_0_OR_GREATER + await using (var stream = contentTypesZipEntry.Open()) +#else using (var stream = contentTypesZipEntry.Open()) +#endif { var doc = XDocument.Load(stream); - var ns = doc.Root.GetDefaultNamespace(); + var ns = doc.Root?.GetDefaultNamespace(); var typesElement = doc.Descendants(ns + "Types").Single(); var partNames = new HashSet(StringComparer.InvariantCultureIgnoreCase); @@ -562,9 +565,14 @@ private async Task CreateZipEntryAsync(string path, string contentType, string c cancellationToken.ThrowIfCancellationRequested(); var entry = _archive.CreateEntry(path, CompressionLevel.Fastest); + +#if NET5_0_OR_GREATER + await using (var zipStream = entry.Open()) +#else using (var zipStream = entry.Open()) - using (var writer = new MiniExcelAsyncStreamWriter(zipStream, _utf8WithBom, _configuration.BufferSize, cancellationToken)) - await writer.WriteAsync(content); +#endif + using (var writer = new MiniExcelAsyncStreamWriter(zipStream, _utf8WithBom, _configuration.BufferSize, cancellationToken)) + await writer.WriteAsync(content); if (!string.IsNullOrEmpty(contentType)) _zipDictionary.Add(path, new ZipPackageInfo(entry, contentType)); @@ -575,7 +583,12 @@ private async Task CreateZipEntryAsync(string path, byte[] content, Cancellation cancellationToken.ThrowIfCancellationRequested(); var entry = _archive.CreateEntry(path, CompressionLevel.Fastest); + +#if NET5_0_OR_GREATER + await using (var zipStream = entry.Open()) +#else using (var zipStream = entry.Open()) +#endif await zipStream.WriteAsync(content, 0, content.Length, cancellationToken); } } diff --git a/src/MiniExcel/OpenXml/ExcelOpenXmlStyles.cs b/src/MiniExcel/OpenXml/ExcelOpenXmlStyles.cs index c6fd4a79..cbe8c119 100644 --- a/src/MiniExcel/OpenXml/ExcelOpenXmlStyles.cs +++ b/src/MiniExcel/OpenXml/ExcelOpenXmlStyles.cs @@ -1,10 +1,10 @@ -namespace MiniExcelLibs.OpenXml -{ - using MiniExcelLibs.Utils; - using MiniExcelLibs.Zip; - using System; - using System.Collections.Generic; +using MiniExcelLibs.Utils; +using MiniExcelLibs.Zip; +using System; +using System.Collections.Generic; +namespace MiniExcelLibs.OpenXml +{ internal class ExcelOpenXmlStyles { private static readonly string[] _ns = { Config.SpreadsheetmlXmlns, Config.SpreadsheetmlXmlStrictns }; @@ -14,68 +14,68 @@ internal class ExcelOpenXmlStyles public ExcelOpenXmlStyles(ExcelOpenXmlZip zip) { - using (var Reader = zip.GetXmlReader(@"xl/styles.xml")) + using (var reader = zip.GetXmlReader(@"xl/styles.xml")) { - if (!XmlReaderHelper.IsStartElement(Reader, "styleSheet", _ns)) + if (!XmlReaderHelper.IsStartElement(reader, "styleSheet", _ns)) return; - if (!XmlReaderHelper.ReadFirstContent(Reader)) + if (!XmlReaderHelper.ReadFirstContent(reader)) return; - while (!Reader.EOF) + + while (!reader.EOF) { - if (XmlReaderHelper.IsStartElement(Reader, "cellXfs", _ns)) + if (XmlReaderHelper.IsStartElement(reader, "cellXfs", _ns)) { - if (!XmlReaderHelper.ReadFirstContent(Reader)) + if (!XmlReaderHelper.ReadFirstContent(reader)) continue; var index = 0; - while (!Reader.EOF) + while (!reader.EOF) { - if (XmlReaderHelper.IsStartElement(Reader, "xf", _ns)) + if (XmlReaderHelper.IsStartElement(reader, "xf", _ns)) { - int.TryParse(Reader.GetAttribute("xfId"), out var xfId); - int.TryParse(Reader.GetAttribute("numFmtId"), out var numFmtId); + int.TryParse(reader.GetAttribute("xfId"), out var xfId); + int.TryParse(reader.GetAttribute("numFmtId"), out var numFmtId); _cellXfs.Add(index, new StyleRecord() { XfId = xfId, NumFmtId = numFmtId }); - Reader.Skip(); + reader.Skip(); index++; } - else if (!XmlReaderHelper.SkipContent(Reader)) + else if (!XmlReaderHelper.SkipContent(reader)) break; } } - else if (XmlReaderHelper.IsStartElement(Reader, "cellStyleXfs", _ns)) + else if (XmlReaderHelper.IsStartElement(reader, "cellStyleXfs", _ns)) { - if (!XmlReaderHelper.ReadFirstContent(Reader)) + if (!XmlReaderHelper.ReadFirstContent(reader)) continue; var index = 0; - while (!Reader.EOF) + while (!reader.EOF) { - if (XmlReaderHelper.IsStartElement(Reader, "xf", _ns)) + if (XmlReaderHelper.IsStartElement(reader, "xf", _ns)) { - int.TryParse(Reader.GetAttribute("xfId"), out var xfId); - int.TryParse(Reader.GetAttribute("numFmtId"), out var numFmtId); + int.TryParse(reader.GetAttribute("xfId"), out var xfId); + int.TryParse(reader.GetAttribute("numFmtId"), out var numFmtId); _cellStyleXfs.Add(index, new StyleRecord() { XfId = xfId, NumFmtId = numFmtId }); - Reader.Skip(); + reader.Skip(); index++; } - else if (!XmlReaderHelper.SkipContent(Reader)) + else if (!XmlReaderHelper.SkipContent(reader)) break; } } - else if (XmlReaderHelper.IsStartElement(Reader, "numFmts", _ns)) + else if (XmlReaderHelper.IsStartElement(reader, "numFmts", _ns)) { - if (!XmlReaderHelper.ReadFirstContent(Reader)) + if (!XmlReaderHelper.ReadFirstContent(reader)) continue; - while (!Reader.EOF) + while (!reader.EOF) { - if (XmlReaderHelper.IsStartElement(Reader, "numFmt", _ns)) + if (XmlReaderHelper.IsStartElement(reader, "numFmt", _ns)) { - int.TryParse(Reader.GetAttribute("numFmtId"), out var numFmtId); - var formatCode = Reader.GetAttribute("formatCode"); - - + int.TryParse(reader.GetAttribute("numFmtId"), out var numFmtId); + var formatCode = reader.GetAttribute("formatCode"); + //TODO: determine the type according to the format var type = typeof(string); if (DateTimeHelper.IsDateTimeFormat(formatCode)) @@ -84,15 +84,15 @@ public ExcelOpenXmlStyles(ExcelOpenXmlZip zip) } _customFormats.Add(numFmtId, new NumberFormatString(formatCode, type)); - Reader.Skip(); + reader.Skip(); } - else if (!XmlReaderHelper.SkipContent(Reader)) + else if (!XmlReaderHelper.SkipContent(reader)) { break; } } } - else if (!XmlReaderHelper.SkipContent(Reader)) + else if (!XmlReaderHelper.SkipContent(reader)) { break; } @@ -102,52 +102,41 @@ public ExcelOpenXmlStyles(ExcelOpenXmlZip zip) public NumberFormatString GetStyleFormat(int index) { - if (_cellXfs.TryGetValue(index, out var styleRecord)) - { - if (Formats.TryGetValue(styleRecord.NumFmtId, out var numberFormat)) - { - return numberFormat; - } - else if (_customFormats.TryGetValue(styleRecord.NumFmtId, out var customNumberFormat)) - { - return customNumberFormat; - } + if (!_cellXfs.TryGetValue(index, out var styleRecord)) return null; - } + + if (Formats.TryGetValue(styleRecord.NumFmtId, out var numberFormat)) + return numberFormat; + + if (_customFormats.TryGetValue(styleRecord.NumFmtId, out var customNumberFormat)) + return customNumberFormat; + return null; } public object ConvertValueByStyleFormat(int index, object value) { - var sf = this.GetStyleFormat(index); - if (sf == null) - return value; - if (sf.Type == null) + var sf = GetStyleFormat(index); + if (sf?.Type == null) return value; if (sf.Type == typeof(DateTime?)) { if (double.TryParse(value?.ToString(), out var s)) { - if (s >= DateTimeHelper.OADateMaxAsDouble || s <= DateTimeHelper.OADateMinAsDouble) - { - return value; - } - return DateTimeHelper.FromOADate(s); + return DateTimeHelper.IsValidOADateTime(s) ? DateTime.FromOADate(s) : value; } } else if (sf.Type == typeof(TimeSpan?)) { if (double.TryParse(value?.ToString(), out var number)) - { return TimeSpan.FromDays(number); - } } return value; } - private static Dictionary Formats { get; } = new Dictionary() + private static Dictionary Formats { get; } = new Dictionary { { 0, new NumberFormatString("General",typeof(string)) }, { 1, new NumberFormatString("0",typeof(decimal?)) }, diff --git a/src/MiniExcel/Utils/CustomPropertyHelper.cs b/src/MiniExcel/Utils/CustomPropertyHelper.cs index c4eb2075..486b5bd7 100644 --- a/src/MiniExcel/Utils/CustomPropertyHelper.cs +++ b/src/MiniExcel/Utils/CustomPropertyHelper.cs @@ -303,10 +303,8 @@ internal static bool TryGetTypeColumnInfo(Type type, Configuration configuration return false; } - if (type.IsValueType) - throw new NotImplementedException($"MiniExcel does not support only {type.Name} value generic type"); - if (type == typeof(string) || type == typeof(DateTime) || type == typeof(Guid)) - throw new NotImplementedException($"MiniExcel does not support only {type.Name} generic type"); + if (type.IsValueType || type == typeof(string)) + throw new NotSupportedException($"MiniExcel does not support the use of {type.FullName} as a generic type"); if (ValueIsNeededToDetermineProperties(type)) { diff --git a/src/MiniExcel/Utils/DateTimeHelper.cs b/src/MiniExcel/Utils/DateTimeHelper.cs index c9da83bb..7b7b60e6 100644 --- a/src/MiniExcel/Utils/DateTimeHelper.cs +++ b/src/MiniExcel/Utils/DateTimeHelper.cs @@ -1,13 +1,6 @@ namespace MiniExcelLibs.Utils { - using System; - -#if DEBUG - public -#else - internal -#endif - static partial class DateTimeHelper + public static class DateTimeHelper { /// /// NumberFormat from NuGet ExcelNumberFormat MIT@License @@ -18,103 +11,14 @@ public static bool IsDateTimeFormat(string formatCode) } /**Below Code from ExcelDataReader @MIT License**/ - // All OA dates must be greater than (not >=) OADateMinAsDouble - public const double OADateMinAsDouble = -657435.0; - - // All OA dates must be less than (not <=) OADateMaxAsDouble - public const double OADateMaxAsDouble = 2958466.0; - - // From DateTime class to enable OADate in PCL - // Number of 100ns ticks per time unit - private const long TicksPerMillisecond = 10000; - private const long TicksPerSecond = TicksPerMillisecond * 1000; - private const long TicksPerMinute = TicksPerSecond * 60; - private const long TicksPerHour = TicksPerMinute * 60; - private const long TicksPerDay = TicksPerHour * 24; - - // Number of milliseconds per time unit - private const int MillisPerSecond = 1000; - private const int MillisPerMinute = MillisPerSecond * 60; - private const int MillisPerHour = MillisPerMinute * 60; - private const int MillisPerDay = MillisPerHour * 24; - - // Number of days in a non-leap year - private const int DaysPerYear = 365; - - // Number of days in 4 years - private const int DaysPer4Years = DaysPerYear * 4 + 1; - - // Number of days in 100 years - private const int DaysPer100Years = DaysPer4Years * 25 - 1; - - // Number of days in 400 years - private const int DaysPer400Years = DaysPer100Years * 4 + 1; - - // Number of days from 1/1/0001 to 12/30/1899 - private const int DaysTo1899 = DaysPer400Years * 4 + DaysPer100Years * 3 - 367; - - // Number of days from 1/1/0001 to 12/31/9999 - private const int DaysTo10000 = DaysPer400Years * 25 - 366; - - private const long MaxMillis = (long)DaysTo10000 * MillisPerDay; - - private const long DoubleDateOffset = DaysTo1899 * TicksPerDay; - - public static DateTime FromOADate(double d) - { - return new DateTime(DoubleDateToTicks(d), DateTimeKind.Unspecified); - } - - // duplicated from DateTime - internal static long DoubleDateToTicks(double value) - { - if (value >= OADateMaxAsDouble || value <= OADateMinAsDouble) - throw new ArgumentException("Invalid OA Date"); - long millis = (long)(value * MillisPerDay + (value >= 0 ? 0.5 : -0.5)); - - // The interesting thing here is when you have a value like 12.5 it all positive 12 days and 12 hours from 01/01/1899 - // However if you a value of -12.25 it is minus 12 days but still positive 6 hours, almost as though you meant -11.75 all negative - // This line below fixes up the millis in the negative case - if (millis < 0) - { - millis -= millis % MillisPerDay * 2; - } - - millis += DoubleDateOffset / TicksPerMillisecond; - - if (millis < 0 || millis >= MaxMillis) - throw new ArgumentException("OA Date out of range"); - return millis * TicksPerMillisecond; - } + // All OA dates must be strictly in between OADateMinAsDouble and OADateMaxAsDouble + private const double OADateMinAsDouble = -657435.0; - public static double AdjustOADateTime(double value, bool date1904) - { - if (!date1904) - { - // Workaround for 1900 leap year bug in Excel - if (value >= 0.0 && value < 60.0) - return value + 1; - } - else - { - return value + 1462.0; - } - - return value; - } + private const double OADateMaxAsDouble = 2958466.0; - public static bool IsValidOADateTime(double value) + internal static bool IsValidOADateTime(double value) { - return value > DateTimeHelper.OADateMinAsDouble && value < DateTimeHelper.OADateMaxAsDouble; - } - - public static object ConvertFromOATime(double value, bool date1904) - { - var dateValue = AdjustOADateTime(value, date1904); - if (IsValidOADateTime(dateValue)) - return DateTimeHelper.FromOADate(dateValue); - return value; + return value > OADateMinAsDouble && value < OADateMaxAsDouble; } } - } diff --git a/src/MiniExcel/Utils/TypeHelper.cs b/src/MiniExcel/Utils/TypeHelper.cs index bcacf328..94da9219 100644 --- a/src/MiniExcel/Utils/TypeHelper.cs +++ b/src/MiniExcel/Utils/TypeHelper.cs @@ -1,15 +1,15 @@ -namespace MiniExcelLibs.Utils -{ - using MiniExcelLibs.Exceptions; - using System; - using System.Collections.Generic; - using System.ComponentModel; - using System.Data; - using System.Globalization; - using System.Linq; - using System.Reflection; +using MiniExcelLibs.Exceptions; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Globalization; +using System.Linq; +using System.Reflection; - internal static partial class TypeHelper +namespace MiniExcelLibs.Utils +{ + internal static class TypeHelper { public static IEnumerable> ConvertToEnumerableDictionary(IDataReader reader) { @@ -20,7 +20,6 @@ public static IEnumerable> ConvertToEnumerableDictio } } - /// /// From : https://stackoverflow.com/questions/906499/getting-type-t-from-ienumerablet /// @@ -125,7 +124,7 @@ public static bool IsNumericType(Type type, bool isNullableUnderlyingType = fals else if (DateTime.TryParseExact(vs, "dd/MM/yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None, out var _v2)) newValue = _v2; else if (double.TryParse(vs, NumberStyles.None, CultureInfo.InvariantCulture, out var _d)) - newValue = DateTimeHelper.FromOADate(_d); + newValue = DateTime.FromOADate(_d); else throw new InvalidCastException($"{vs} cannot be cast to DateTime"); } diff --git a/tests/MiniExcelTests/MiniExcelCsvAsycTests.cs b/tests/MiniExcelTests/MiniExcelCsvAsycTests.cs index f9730a4f..88394141 100644 --- a/tests/MiniExcelTests/MiniExcelCsvAsycTests.cs +++ b/tests/MiniExcelTests/MiniExcelCsvAsycTests.cs @@ -77,7 +77,7 @@ public async Task SaveAsByDictionary() { var path = Path.Combine(Path.GetTempPath(), $"{Guid.NewGuid()}.csv"); var table = new Dictionary(); //TODO - Assert.Throws(() => MiniExcel.SaveAs(path, table)); + Assert.Throws(() => MiniExcel.SaveAs(path, table)); File.Delete(path); } diff --git a/tests/MiniExcelTests/MiniExcelCsvTests.cs b/tests/MiniExcelTests/MiniExcelCsvTests.cs index 4f8bb905..6f75699c 100644 --- a/tests/MiniExcelTests/MiniExcelCsvTests.cs +++ b/tests/MiniExcelTests/MiniExcelCsvTests.cs @@ -114,7 +114,7 @@ public void SaveAsByDictionary() { var path = Path.Combine(Path.GetTempPath(), $"{Guid.NewGuid()}.csv"); var table = new Dictionary(); //TODO - Assert.Throws(() => MiniExcel.SaveAs(path, table)); + Assert.Throws(() => MiniExcel.SaveAs(path, table)); File.Delete(path); } diff --git a/tests/MiniExcelTests/MiniExcelIssueAsyncTests.cs b/tests/MiniExcelTests/MiniExcelIssueAsyncTests.cs index 89bfd032..5c26f344 100644 --- a/tests/MiniExcelTests/MiniExcelIssueAsyncTests.cs +++ b/tests/MiniExcelTests/MiniExcelIssueAsyncTests.cs @@ -1462,15 +1462,15 @@ public async Task Issue150() { var path = Path.Combine(Path.GetTempPath(), $"{Guid.NewGuid().ToString()}.xlsx"); //MiniExcel.SaveAs(path, new[] { "1", "2" }); - await Assert.ThrowsAnyAsync(async () => await MiniExcel.SaveAsAsync(path, new[] { 1, 2 })); + await Assert.ThrowsAnyAsync(async () => await MiniExcel.SaveAsAsync(path, new[] { 1, 2 })); File.Delete(path); - await Assert.ThrowsAnyAsync(async () => await MiniExcel.SaveAsAsync(path, new[] { "1", "2" })); + await Assert.ThrowsAnyAsync(async () => await MiniExcel.SaveAsAsync(path, new[] { "1", "2" })); File.Delete(path); - await Assert.ThrowsAnyAsync(async () => await MiniExcel.SaveAsAsync(path, new[] { '1', '2' })); + await Assert.ThrowsAnyAsync(async () => await MiniExcel.SaveAsAsync(path, new[] { '1', '2' })); File.Delete(path); - await Assert.ThrowsAnyAsync(async () => await MiniExcel.SaveAsAsync(path, new[] { DateTime.Now })); + await Assert.ThrowsAnyAsync(async () => await MiniExcel.SaveAsAsync(path, new[] { DateTime.Now })); File.Delete(path); - await Assert.ThrowsAnyAsync(async () => await MiniExcel.SaveAsAsync(path, new[] { Guid.NewGuid() })); + await Assert.ThrowsAnyAsync(async () => await MiniExcel.SaveAsAsync(path, new[] { Guid.NewGuid() })); File.Delete(path); } diff --git a/tests/MiniExcelTests/MiniExcelIssueTests.cs b/tests/MiniExcelTests/MiniExcelIssueTests.cs index 8270b9a2..c7c01a36 100644 --- a/tests/MiniExcelTests/MiniExcelIssueTests.cs +++ b/tests/MiniExcelTests/MiniExcelIssueTests.cs @@ -19,6 +19,7 @@ using System.Text; using System.Text.RegularExpressions; using System.Threading.Tasks; +using MiniExcelLibs.Utils; using Xunit; using Xunit.Abstractions; using static MiniExcelLibs.Tests.MiniExcelOpenXmlTests; @@ -1749,7 +1750,7 @@ public void TestIssue268_DateFormat() private static bool IsDateFormatString(string formatCode) { - return MiniExcelLibs.Utils.DateTimeHelper.IsDateTimeFormat(formatCode); + return DateTimeHelper.IsDateTimeFormat(formatCode); } [Fact] @@ -3176,15 +3177,15 @@ public void Issue150() { var path = Path.Combine(Path.GetTempPath(), $"{Guid.NewGuid()}.xlsx"); //MiniExcel.SaveAs(path, new[] { "1", "2" }); - Assert.Throws(() => MiniExcel.SaveAs(path, new[] { 1, 2 })); + Assert.Throws(() => MiniExcel.SaveAs(path, new[] { 1, 2 })); File.Delete(path); - Assert.Throws(() => MiniExcel.SaveAs(path, new[] { "1", "2" })); + Assert.Throws(() => MiniExcel.SaveAs(path, new[] { "1", "2" })); File.Delete(path); - Assert.Throws(() => MiniExcel.SaveAs(path, new[] { '1', '2' })); + Assert.Throws(() => MiniExcel.SaveAs(path, new[] { '1', '2' })); File.Delete(path); - Assert.Throws(() => MiniExcel.SaveAs(path, new[] { DateTime.Now })); + Assert.Throws(() => MiniExcel.SaveAs(path, new[] { DateTime.Now })); File.Delete(path); - Assert.Throws(() => MiniExcel.SaveAs(path, new[] { Guid.NewGuid() })); + Assert.Throws(() => MiniExcel.SaveAs(path, new[] { Guid.NewGuid() })); File.Delete(path); } diff --git a/tests/MiniExcelTests/MiniExcelOpenXmlAsyncTests.cs b/tests/MiniExcelTests/MiniExcelOpenXmlAsyncTests.cs index b4de8f3f..00c2997c 100644 --- a/tests/MiniExcelTests/MiniExcelOpenXmlAsyncTests.cs +++ b/tests/MiniExcelTests/MiniExcelOpenXmlAsyncTests.cs @@ -613,7 +613,7 @@ public async Task SaveAsFileWithDimensionByICollection() { var path = Path.Combine(Path.GetTempPath(), $"{Guid.NewGuid()}.xlsx"); var values = new List(); - Assert.Throws(() => MiniExcel.SaveAsAsync(path, values).GetAwaiter().GetResult()); + Assert.Throws(() => MiniExcel.SaveAsAsync(path, values).GetAwaiter().GetResult()); File.Delete(path); } } diff --git a/tests/MiniExcelTests/MiniExcelOpenXmlTests.cs b/tests/MiniExcelTests/MiniExcelOpenXmlTests.cs index 4ff82d00..279d4c36 100644 --- a/tests/MiniExcelTests/MiniExcelOpenXmlTests.cs +++ b/tests/MiniExcelTests/MiniExcelOpenXmlTests.cs @@ -648,7 +648,7 @@ public void SaveAsFileWithDimensionByICollection() { var path = Path.Combine(Path.GetTempPath(), $"{Guid.NewGuid()}.xlsx"); var values = new List(); - Assert.Throws(() => MiniExcel.SaveAs(path, values)); + Assert.Throws(() => MiniExcel.SaveAs(path, values)); } }