Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

confusing warning when checking if name exists #38

Merged
merged 1 commit into from
Aug 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions src/main/java/com/miraisolutions/xlconnect/Workbook.java
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,6 @@ public ResultWithAttributes<Boolean> existsName(String name, String worksheetSco
String foundInScope = effectiveScope(worksheetScope, found);
return new ResultWithAttributes<Boolean>(true, WORKSHEET_SCOPE, foundInScope);
} catch (IllegalArgumentException ignored) {
warnings.add(ignored.getMessage());
return worksheetScope != null ? new ResultWithAttributes<Boolean>(false, WORKSHEET_SCOPE, worksheetScope)
: new ResultWithAttributes<Boolean>(false);
}
Expand Down Expand Up @@ -995,12 +994,12 @@ private Name getName(String name, String worksheetScope) {
StringBuffer names = new StringBuffer();
String worksheetScopeDisplay = displayWorksheetScope(worksheetScope);
cNames.forEach(n -> names.append(n.getSheetIndex() >= 0 ? workbook.getSheetName(n.getSheetIndex()) : "global scope").append(";"));
throw new IllegalArgumentException("Name '" + name + "' was not specified '" + worksheetScopeDisplay + "'! " +
throw new IllegalArgumentException("Name '" + name + "' was not specified " + worksheetScopeDisplay + "! " +
"Found in sheets: " + names);
}

private String displayWorksheetScope(String worksheetScope) {
return null == worksheetScope ? "" : worksheetScope.isEmpty() ? "in global scope" : "in " +worksheetScope;
return null == worksheetScope ? "" : worksheetScope.isEmpty() ? "in global scope" : "in '" +worksheetScope+ "'";
}

// Checks only if the reference as such is valid
Expand Down