Skip to content

Commit

Permalink
layout fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
dcrasch committed May 19, 2022
1 parent 023b5d4 commit a5d8703
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 21 deletions.
16 changes: 1 addition & 15 deletions src/XLParser.Tests/FormulaAnalysisTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,6 @@ public void ExternalWorkbookUrlPathHttp()
public void ExternalWorkbookUrlPathHttpWithSpaceInPath()
{
// See [#138](https://github.com/spreadsheetlab/XLParser/issues/138)

List<ParserReference> references = new FormulaAnalyzer(@"='http://example.com/test folder/[Book1.xlsx]Sheet1'!$A$1").ParserReferences().ToList();

Assert.AreEqual(1, references.Count);
Expand All @@ -375,7 +374,6 @@ public void ExternalWorkbookUrlPathHttpWithSpaceInPath()
public void ExternalWorkbookUrlPathHttpWithSpaceInDocument()
{
// See [#138](https://github.com/spreadsheetlab/XLParser/issues/138)

List<ParserReference> references = new FormulaAnalyzer(@"='http://example.com/testfolder/[Book 1.xlsx]Sheet1'!$A$1").ParserReferences().ToList();

Assert.AreEqual(1, references.Count);
Expand All @@ -388,7 +386,6 @@ public void ExternalWorkbookUrlPathHttpWithSpaceInDocument()
public void ExternalWorkbookNetworkPathWithSpace()
{
// See [#142](https://github.com/spreadsheetlab/XLParser/issues/142)

List<ParserReference> references = new FormulaAnalyzer(@"='\\networkshare\test folder$\[Book 1.xlsx]Sheet1'!$C$33").ParserReferences().ToList();

Assert.AreEqual(1, references.Count);
Expand All @@ -401,7 +398,6 @@ public void ExternalWorkbookNetworkPathWithSpace()
public void ExternalWorkbookNetworkPathWithoutSpaceInFolder()
{
// See [#142](https://github.com/spreadsheetlab/XLParser/issues/142)

List<ParserReference> references = new FormulaAnalyzer(@"='\\networkshare\testfolder$\[Book 1.xlsx]Sheet1'!$C$33").ParserReferences().ToList();

Assert.AreEqual(1, references.Count);
Expand All @@ -414,7 +410,6 @@ public void ExternalWorkbookNetworkPathWithoutSpaceInFolder()
public void ExternalWorkbookNetworkPathWithQuotes()
{
// See [#135](https://github.com/spreadsheetlab/XLParser/issues/135)

List<ParserReference> references = new FormulaAnalyzer(@"='\\SRV01\[TestFile.xls]TestSheet'!#REF!").ParserReferences().ToList();

Assert.AreEqual(1, references.Count);
Expand All @@ -427,7 +422,6 @@ public void ExternalWorkbookNetworkPathWithQuotes()
public void ExternalWorkbookNetworkPathWithQuotesAndSpaces()
{
// See [#135](https://github.com/spreadsheetlab/XLParser/issues/135)

List<ParserReference> references = new FormulaAnalyzer(@"='\\SRV01\[Test File.xls]Test Sheet'!#REF!").ParserReferences().ToList();

Assert.AreEqual(1, references.Count);
Expand All @@ -440,7 +434,6 @@ public void ExternalWorkbookNetworkPathWithQuotesAndSpaces()
public void ExternalWorkbookNetworkPathWithQuotesAndSpaceInFolder()
{
// See [#135](https://github.com/spreadsheetlab/XLParser/issues/135)

List<ParserReference> references = new FormulaAnalyzer(@"='\\SRV01\Test Folder\[TestFile.xls]Test Sheet'!#REF!").ParserReferences().ToList();

Assert.AreEqual(1, references.Count);
Expand All @@ -453,10 +446,7 @@ public void ExternalWorkbookNetworkPathWithQuotesAndSpaceInFolder()
public void ExternalWorkbookNetworkPathWithQuotesAndSpaceInDocument()
{
// See [#135](https://github.com/spreadsheetlab/XLParser/issues/135)

List<ParserReference> references = new FormulaAnalyzer(@"='\\SRV01\TestFolder\[Test File.xls]Test Sheet'!#REF!
").ParserReferences().ToList();
List<ParserReference> 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);
Expand Down Expand Up @@ -524,7 +514,6 @@ public void ExternalWorkbookRelativePathIsDefinedName()
public void ExternalWorkbookUrlPathHttpWithRoundBracketsInDocument()
{
// See [#140](https://github.com/spreadsheetlab/XLParser/issues/140)

List<ParserReference> references = new FormulaAnalyzer(@"='http://example.com/testfolder(brackets)/[Book 1.xlsx]Sheet1'!$A$1").ParserReferences().ToList();

Assert.AreEqual(1, references.Count);
Expand All @@ -537,7 +526,6 @@ public void ExternalWorkbookUrlPathHttpWithRoundBracketsInDocument()
public void ExternalWorkbookUrlPathHttpWithRoundBrackets()
{
// See [#140](https://github.com/spreadsheetlab/XLParser/issues/140)

List<ParserReference> references = new FormulaAnalyzer(@"='http://example.com/testfolder(brackets)/[Book (1).xlsx]Sheet1'!$A$1").ParserReferences().ToList();

Assert.AreEqual(1, references.Count);
Expand All @@ -550,7 +538,6 @@ public void ExternalWorkbookUrlPathHttpWithRoundBrackets()
public void ExternalWorkbookPathWithRoundBracketsInDocument()
{
// See [#140](https://github.com/spreadsheetlab/XLParser/issues/140)

List<ParserReference> references = new FormulaAnalyzer(@"='c:\My documents\[Book 1 (copy).xlsx]Sheet1'!$A$1").ParserReferences().ToList();

Assert.AreEqual(1, references.Count);
Expand All @@ -563,7 +550,6 @@ public void ExternalWorkbookPathWithRoundBracketsInDocument()
public void ExternalWorkbookPathWithRoundBrackets()
{
// See [#140](https://github.com/spreadsheetlab/XLParser/issues/140)

List<ParserReference> references = new FormulaAnalyzer(@"='c:\My documents (copy)\[Book 1 (copy).xlsx]Sheet1'!$A$1").ParserReferences().ToList();

Assert.AreEqual(1, references.Count);
Expand Down
9 changes: 3 additions & 6 deletions src/XLParser/ExcelFormulaGrammar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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\-.$ ]+)\\(([^<>:\""/\|?*\\]| )+\\)*";
Expand Down Expand Up @@ -391,10 +391,7 @@ public ExcelFormulaGrammar() : base(false)

DynamicDataExchange.Rule = File + exclamationMark + SingleQuotedStringToken;

NamedRange.Rule =
NameToken
| NamedRangeCombinationToken
;
NamedRange.Rule = NameToken | NamedRangeCombinationToken;

Prefix.Rule =
SheetToken
Expand Down

0 comments on commit a5d8703

Please sign in to comment.