Skip to content

Commit

Permalink
Add release notes.
Browse files Browse the repository at this point in the history
Bump version.
Obsolete Async method (wasn't properly async anyway).
  • Loading branch information
MarkPflug committed Sep 7, 2023
1 parent baa8e9c commit ff487e4
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 15 deletions.
4 changes: 4 additions & 0 deletions docs/ReleaseNotes.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Sylvan.Data.Excel Release Notes

_0.4.16_
- Adds ExcelFileType class that exposes constants about supported Excel formats: extensions and content types.
- Add `Obsolete` to `TryOpenWorksheetAsync`, use `TryOpenWorksheet` instead. Information about future Async strategy will be forthcoming.

_0.4.15_
- Fix a bug that prevented .xlsx reader from working on .NET Framework versions.
- Fix a bug where FieldRowCount would be incorrect on empty rows.
Expand Down
18 changes: 4 additions & 14 deletions source/Sylvan.Data.Excel/ExcelDataReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
using System.Globalization;
using System.IO;
using System.Linq;
using System.Net;
using System.Threading;
using System.Threading.Tasks;

Expand Down Expand Up @@ -175,24 +174,12 @@ public static ExcelDataReader Create(Stream stream, ExcelWorkbookType fileType,
}
}

static readonly Dictionary<string, ExcelWorkbookType> FileTypeMap = new(StringComparer.OrdinalIgnoreCase)
{
{ ".xls", ExcelWorkbookType.Excel },
{ ".xlsx", ExcelWorkbookType.ExcelXml },
{ ".xlsm", ExcelWorkbookType.ExcelXml },
{ ".xlsb", ExcelWorkbookType.ExcelBinary },
};

/// <summary>
/// Gets the type of an Excel workbook from the file name.
/// </summary>
public static ExcelWorkbookType GetWorkbookType(string filename)
{
var ext = Path.GetExtension(filename);
return
FileTypeMap.TryGetValue(ext, out var type)
? type
: 0;
return ExcelFileType.FindForFilename(filename)?.WorkbookType ?? ExcelWorkbookType.Unknown;
}

/// <summary>
Expand All @@ -202,7 +189,9 @@ public static ExcelWorkbookType GetWorkbookType(string filename)
/// <returns>True if the sheet was opened, otherwise false.</returns>
public bool TryOpenWorksheet(string name)
{
#pragma warning disable // disable obsolete warning for now.
return TryOpenWorksheetAsync(name).GetAwaiter().GetResult();
#pragma warning enable
}

/// <summary>
Expand All @@ -211,6 +200,7 @@ public bool TryOpenWorksheet(string name)
/// <param name="name">The name of the worksheet to open.</param>
/// <param name="cancel">A cancellation token for the async operation.</param>
/// <returns>True if the sheet was opened, otherwise false.</returns>
[Obsolete("TryOpenWorksheetAsync will be removed in a future version. Use TryOpenWorksheet instead.")]
public Task<bool> TryOpenWorksheetAsync(string name, CancellationToken cancel = default)
{
var sheetIdx = -1;
Expand Down
2 changes: 1 addition & 1 deletion source/Sylvan.Data.Excel/Sylvan.Data.Excel.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<TargetFrameworks>net6.0;netstandard2.1;netstandard2.0</TargetFrameworks>
<LangVersion>latest</LangVersion>
<VersionPrefix>0.4.15</VersionPrefix>
<VersionPrefix>0.4.16</VersionPrefix>
<Description>A cross-platform .NET library for reading Excel data files.</Description>
<PackageTags>excel;xls;xlsx;xlsb;datareader</PackageTags>
<Nullable>enable</Nullable>
Expand Down

0 comments on commit ff487e4

Please sign in to comment.