i trying generate formula this, sample,
a + b + c > d -
now, a, b, c, d, etc column names of sheet (like excel sheet) accessing in memory.
i need generate rule, above a + b + c > d - a
decide kind of values user can add in cell.
currently how have begun:
string tovalidate = "a + b + c > d + e - a"; string lhs = "", rhs = ""; string[] comparisonoperators = new string[] { "=", ">", "<", "<>", "!=" }; char[] arithmeticoperators = { '+', '-', '/', '*' }; tovalidate = tovalidate.replace(@" ", ""); (int = 0; < comparisonoperators.length; i++) { if (tovalidate.contains(comparisonoperators[i])) { operatorindex = tovalidate.indexof(comparisonoperators[i]); break; } } lhs = tovalidate.substring(0, operatorindex); rhs = tovalidate.substring(operatorindex + 1); string[] columnlhslist = lhs.split(arithmeticoperators); string[] columnrhslist = rhs.split(arithmeticoperators);
however though have strings lhs
, rhs
, operator >
in above code, not able understand how can apply formula on sheet itself. need know column has operator associated.
since have individual column names, not operator before them, e.g,
+
before a
-
before a
in case.
how parse above please help.
it is, however, fun question if want make simple formula parsers yourself.
i advice check out article, since written , understandable because of it.
Comments
Post a Comment