From 5e8853c7ec71c812a15373ed1f3192e656d715ad Mon Sep 17 00:00:00 2001 From: Shun-ichi Goto Date: Fri, 24 Jun 2022 17:48:11 +0900 Subject: [PATCH] accept upper case extension Treat ".CSV" as csv file by comparing filename extension case-insensitively. Also ".TSV" as tsv file. --- ExcelMerge/ExcelWorkbook.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/ExcelMerge/ExcelWorkbook.cs b/ExcelMerge/ExcelWorkbook.cs index 0f0d0a9..6553670 100644 --- a/ExcelMerge/ExcelWorkbook.cs +++ b/ExcelMerge/ExcelWorkbook.cs @@ -15,10 +15,11 @@ public ExcelWorkbook() public static ExcelWorkbook Create(string path, ExcelSheetReadConfig config) { - if (Path.GetExtension(path) == ".csv") + var ext = Path.GetExtension(path).ToLower(); + if (ext == ".csv") return CreateFromCsv(path, config); - if (Path.GetExtension(path) == ".tsv") + if (ext == ".tsv") return CreateFromTsv(path, config); var srcWb = WorkbookFactory.Create(path); @@ -34,11 +35,12 @@ public static ExcelWorkbook Create(string path, ExcelSheetReadConfig config) public static IEnumerable GetSheetNames(string path) { - if (Path.GetExtension(path) == ".csv") + var ext = Path.GetExtension(path).ToLower(); + if (ext == ".csv") { yield return "csv"; } - else if (Path.GetExtension(path) == ".tsv") + else if (ext == ".tsv") { yield return "tsv"; }