-
Notifications
You must be signed in to change notification settings - Fork 807
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
Fix CONCATENATE for cell references #1266
Fix CONCATENATE for cell references #1266
Conversation
var columnCount = cellRangeReference.Range.RangeAddress.LastAddress.ColumnNumber - cellRangeReference.Range.RangeAddress.FirstAddress.ColumnNumber + 1; | ||
|
||
if (columnCount > 1) | ||
throw new CellValueException("This function does not accept cell ranges as parameters."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, so the transpose is also valid.
In the screenshot you pasted, only E3 and F3 would currently be possble. So what should we do? Either return wrong values or throw an exception?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it is time to implement context-dependent functions? Like ROW()
, COLUMN()
, etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, we should. But for now we need to fix this regression. I think we just return 1 text
or 5 text
for each value in the column/row.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not convinced that this is a regression as this function never worked with range references as it should. I would prefer the function screaming out loud that it is not fully implemented (=throw an exception) rather than silently returning an incorrect result that might be extremely hard to trace should it cause the error far down the stream.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The above use-case isn't a regression, but the CONCATENATE(A1, B1)
case is a regression.
Yes, I now agree with you. Let's throw an exception. I doubt many people use that edge case anyway.
ef66263
to
064b1e4
Compare
Added some |
{ | ||
var ws = new XLWorkbook().AddWorksheet() as XLWorksheet; | ||
|
||
var range = ws.Range("B3:E5"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Try also B5:E3
and E5:B3
. The results must be the same (now they are not). I suggest using Normalize()
in the implementation.
064b1e4
to
b0a7b02
Compare
@Pankraty Happy to merge? |
CONCATENATE may accept cell range references as parameters, but its implementation is tricky and we can't support the full scope that Excel supports. See added code comments for clarification. This improves it though.
Fixes #1264