Hi,
I have an UltraCalcManager to which I have added a formula.
While I know that the calc manager will happily work out the result of the formula for me; I am interested in finding out the elements that are in play within the formula.
So, a formula of:
( a + b ) * ( c + 10)
I want to know that I've got:
a, b, c and 10 involved in the formula.
Is this possible with the UltraCalcManager (in version 10.3)?
TIA
Alan
Hello Alan,
I`m not sure that I understand well your questions, but maybe one possible way to find the elements (for example columns, values and etc. – if a,b,c are your columns in the UltraGird ) which are include in the formula is to handle ultraGrid1_SummaryValueChanged() and check the properties:
-SummarySettings sumSettings = e.SummaryValue.SummarySettings;
-UltraGridColumn gc = sumSettings.SourceColumn;
-string formula = sumSettings.Formula;
By using the UltraCalcManager you are able to use the different functions in the FormulaBuilder class. Please let me know if you think that I misunderstood your requirements or if you have any questions.
Regards
Georgi
Hi Georgi,
I think you mis-understand and I probably didn't do a great job of explaining.
I have the UltraCalcManager, but I'm not using it in the context of a grid here (it is in other places; but the specifics of what I want here are outside of the grid).
I have a forumla that has been generated through a formula builder (custom built) and the formula has been validated through the calc manager so syntatically I know it is correct.
What I want to do is to work out how many fields are in use in the formula and how many constants there are. The reason for this being I need to do some specific behaviour elsewhere in the event that the field has no value (so rows in a table are not repeating values unnecessarily)
As a result of this, I was hoping to get hold of the parsed expression tree so that I can interogate to find out what is in use in the formula and hence whether I need to invoke some row removal elsewhere.
Hope that makes a little more sense
Cheers
Cheers Mike,
I had a feeling that would be the case as I couldn't see anything obvious to be able to get down to the expression tree
Thanks
Hi Alan,
I beleive this is technically possible to do, but it's not trivial and I'm not sure exactly how you would go about it off the top of my head. It might require several days of coding and some trial-and-error.
If you own a subscription to NetAdvantage that includes the source code, then I would recommend that you check out the formula exporting support in the UltraGridExcelExporter. This component has to do essentially what you are describing (plus a whole lot more).
Basically, the component parses the formulas, then walks over the parts in order to convert those formulas into corresponding formulas in Excel.
If you don't own the source code, then I don't see any way to do this, and there's no way I could even attempt to explain how it might be done here in a forum post - it's far too complex a process.