Search code examples
excelkeyboard-shortcutsexcel-dna

ExcelDNA C# xll - When using the formula they suddenly disappear if Ctrl+Z is accidentally pressed?


ExcelDNA C# xll - When using the formula they suddenly disappear if Ctrl+Z is accidentally pressed?!

Has anyone experienced this? The behavior of my code (xll addin calls another custom dll) is as expected and we're (my manager and I) now testing it and she saw this behavior. I can also reproduce it too.

Is it specific to something in ExcelDNA or has anyone seen this in Excel?

We know, being seasoned developers since the 90s, about the standard Ctrl+Z behaviour, however the Ctrl+Z behaviour should just undo the edits performed in other areas of the standard sheet however it wipes out the custom function (really calling C# xll).

Also, the custom returns a 2d array / array formula. Is it something to do with array formulae?


Solution

  • Ah, my fault! :)

    Thanks for the fast comments. So this is the reason why! As you see I fire a query once loads of stuff is correctly passed in. I clean up the 2D arrays (dimensionFilters and measureFilters) removing ExcelEmpty but I'd forgotten to clean up the dimenions and measures arrays. We'd removed a value from one of the arrays for dimensions, which made the query throw an error resulting in a String going back to Excel in place of a 2D array. A subsequent Ctrl+Z removes that String meaning the formula appears to disappear.

    If you do Ctrl+Y the error string/String from me re-appears and if you add back in the value that is missing the query runs and the 2D array formula reappears.

    This is a complex work in progress so I will think about how to handle this situation.