diff --git a/src/XLParser.Tests/FormulaAnalysisTest.cs b/src/XLParser.Tests/FormulaAnalysisTest.cs index e06f413..ab62829 100644 --- a/src/XLParser.Tests/FormulaAnalysisTest.cs +++ b/src/XLParser.Tests/FormulaAnalysisTest.cs @@ -362,7 +362,6 @@ public void ExternalWorkbookUrlPathHttp() public void ExternalWorkbookUrlPathHttpWithSpaceInPath() { // See [#138](https://github.com/spreadsheetlab/XLParser/issues/138) - List references = new FormulaAnalyzer(@"='http://example.com/test folder/[Book1.xlsx]Sheet1'!$A$1").ParserReferences().ToList(); Assert.AreEqual(1, references.Count); @@ -375,7 +374,6 @@ public void ExternalWorkbookUrlPathHttpWithSpaceInPath() public void ExternalWorkbookUrlPathHttpWithSpaceInDocument() { // See [#138](https://github.com/spreadsheetlab/XLParser/issues/138) - List references = new FormulaAnalyzer(@"='http://example.com/testfolder/[Book 1.xlsx]Sheet1'!$A$1").ParserReferences().ToList(); Assert.AreEqual(1, references.Count); @@ -388,7 +386,6 @@ public void ExternalWorkbookUrlPathHttpWithSpaceInDocument() public void ExternalWorkbookNetworkPathWithSpace() { // See [#142](https://github.com/spreadsheetlab/XLParser/issues/142) - List references = new FormulaAnalyzer(@"='\\networkshare\test folder$\[Book 1.xlsx]Sheet1'!$C$33").ParserReferences().ToList(); Assert.AreEqual(1, references.Count); @@ -401,7 +398,6 @@ public void ExternalWorkbookNetworkPathWithSpace() public void ExternalWorkbookNetworkPathWithoutSpaceInFolder() { // See [#142](https://github.com/spreadsheetlab/XLParser/issues/142) - List references = new FormulaAnalyzer(@"='\\networkshare\testfolder$\[Book 1.xlsx]Sheet1'!$C$33").ParserReferences().ToList(); Assert.AreEqual(1, references.Count); @@ -414,7 +410,6 @@ public void ExternalWorkbookNetworkPathWithoutSpaceInFolder() public void ExternalWorkbookNetworkPathWithQuotes() { // See [#135](https://github.com/spreadsheetlab/XLParser/issues/135) - List references = new FormulaAnalyzer(@"='\\SRV01\[TestFile.xls]TestSheet'!#REF!").ParserReferences().ToList(); Assert.AreEqual(1, references.Count); @@ -427,7 +422,6 @@ public void ExternalWorkbookNetworkPathWithQuotes() public void ExternalWorkbookNetworkPathWithQuotesAndSpaces() { // See [#135](https://github.com/spreadsheetlab/XLParser/issues/135) - List references = new FormulaAnalyzer(@"='\\SRV01\[Test File.xls]Test Sheet'!#REF!").ParserReferences().ToList(); Assert.AreEqual(1, references.Count); @@ -440,7 +434,6 @@ public void ExternalWorkbookNetworkPathWithQuotesAndSpaces() public void ExternalWorkbookNetworkPathWithQuotesAndSpaceInFolder() { // See [#135](https://github.com/spreadsheetlab/XLParser/issues/135) - List references = new FormulaAnalyzer(@"='\\SRV01\Test Folder\[TestFile.xls]Test Sheet'!#REF!").ParserReferences().ToList(); Assert.AreEqual(1, references.Count); @@ -453,10 +446,7 @@ public void ExternalWorkbookNetworkPathWithQuotesAndSpaceInFolder() public void ExternalWorkbookNetworkPathWithQuotesAndSpaceInDocument() { // See [#135](https://github.com/spreadsheetlab/XLParser/issues/135) - - List references = new FormulaAnalyzer(@"='\\SRV01\TestFolder\[Test File.xls]Test Sheet'!#REF! - -").ParserReferences().ToList(); + List references = new FormulaAnalyzer(@"='\\SRV01\TestFolder\[Test File.xls]Test Sheet'!#REF!").ParserReferences().ToList(); Assert.AreEqual(1, references.Count); Assert.AreEqual(@"\\SRV01\TestFolder\", references.First().FilePath); @@ -524,7 +514,6 @@ public void ExternalWorkbookRelativePathIsDefinedName() public void ExternalWorkbookUrlPathHttpWithRoundBracketsInDocument() { // See [#140](https://github.com/spreadsheetlab/XLParser/issues/140) - List references = new FormulaAnalyzer(@"='http://example.com/testfolder(brackets)/[Book 1.xlsx]Sheet1'!$A$1").ParserReferences().ToList(); Assert.AreEqual(1, references.Count); @@ -537,7 +526,6 @@ public void ExternalWorkbookUrlPathHttpWithRoundBracketsInDocument() public void ExternalWorkbookUrlPathHttpWithRoundBrackets() { // See [#140](https://github.com/spreadsheetlab/XLParser/issues/140) - List references = new FormulaAnalyzer(@"='http://example.com/testfolder(brackets)/[Book (1).xlsx]Sheet1'!$A$1").ParserReferences().ToList(); Assert.AreEqual(1, references.Count); @@ -550,7 +538,6 @@ public void ExternalWorkbookUrlPathHttpWithRoundBrackets() public void ExternalWorkbookPathWithRoundBracketsInDocument() { // See [#140](https://github.com/spreadsheetlab/XLParser/issues/140) - List references = new FormulaAnalyzer(@"='c:\My documents\[Book 1 (copy).xlsx]Sheet1'!$A$1").ParserReferences().ToList(); Assert.AreEqual(1, references.Count); @@ -563,7 +550,6 @@ public void ExternalWorkbookPathWithRoundBracketsInDocument() public void ExternalWorkbookPathWithRoundBrackets() { // See [#140](https://github.com/spreadsheetlab/XLParser/issues/140) - List references = new FormulaAnalyzer(@"='c:\My documents (copy)\[Book 1 (copy).xlsx]Sheet1'!$A$1").ParserReferences().ToList(); Assert.AreEqual(1, references.Count); diff --git a/src/XLParser/ExcelFormulaGrammar.cs b/src/XLParser/ExcelFormulaGrammar.cs index b108548..4589423 100644 --- a/src/XLParser/ExcelFormulaGrammar.cs +++ b/src/XLParser/ExcelFormulaGrammar.cs @@ -176,12 +176,12 @@ public class ExcelFormulaGrammar : Grammar private const string fileNameInBracketsRegex = @"\[[^\[\]]+\]"; public Terminal FileNameEnclosedInBracketsToken { get; } = new RegexBasedTerminal(GrammarNames.TokenFileNameEnclosedInBrackets, fileNameInBracketsRegex) - { Priority = TerminalPriority.FileName }; + { Priority = TerminalPriority.FileName }; // Source: https://stackoverflow.com/a/14632579 private const string fileNameRegex = @"[^\.\\]+\..{1,4}"; public Terminal FileName { get; } = new RegexBasedTerminal(GrammarNames.TokenFileName, fileNameRegex) - { Priority = TerminalPriority.FileName }; + { Priority = TerminalPriority.FileName }; // Source: http://stackoverflow.com/a/6416209/572635 private const string windowsFilePathRegex = @"(?:[a-zA-Z]:|\\?\\?[\w\-.$ ]+)\\(([^<>:\""/\|?*\\]| )+\\)*"; @@ -391,10 +391,7 @@ public ExcelFormulaGrammar() : base(false) DynamicDataExchange.Rule = File + exclamationMark + SingleQuotedStringToken; - NamedRange.Rule = - NameToken - | NamedRangeCombinationToken - ; + NamedRange.Rule = NameToken | NamedRangeCombinationToken; Prefix.Rule = SheetToken