Free Support Forum - aspose.com

Parsing Excel formulas


#1

Is there a way to parse Excel formula - ideally receiving the formula name and a list of arguments?
Thanks, Tal


#2

@talyifat,

Thanks for your query.

Well, Aspose.Cells has its formula calculation engine to read, write, manipulate and calculate MS Excel formulas. You may use Cell.Formula Property to get/set the formula string of the cell, later on you may write your own code to split complete formula string for your needs. And you may use Cell.StringValue Property to get the resultant value. To get the result of a formula at runtime, you will use this property after calling Workbook.CalculateFormula() method, so all the formulas/functions in workbook would be calculated. See the documents in the section for your complete reference:
e.g
https://docs.aspose.com/display/cellsnet/Using+Formulas+or+Functions+to+Process+Data
https://docs.aspose.com/display/cellsnet/Ways+to+Calculate+Formulas

Hope, this helps a bit.


#3

Thank you for the quick reply, Amjad.

I am aware of the options you mentioned. The problem I am looking for help with is the splitting of the complete formula string into the formula and its arguments (ideally with identification each argument). I have been experimenting with writing my own code for it, but since I would like to support every possible function, that would be a huge undertaking. Are you aware of a tool (by Aspose or otherwise) that could help me with this task?

Since you can calculate functions, it seems like you have the ability to parse and understand formulas and their arguments, at least internally.

Thanks,
Tal


#4

@talyifat,

I am afraid, we might not disclose internal modules of formula calculation engine, you have to write your own logic and code by yourselves.

Also, I am not sure if there is any tool available to parse the MS Excel formulas the way you want.


#5

Thanks, Amjad!

If anyone in the community is aware f such a tool, please share it.

Tal


#6

@talyifat,

You are welcome and feel free to contact us any time if you need further help or have some other issue or queries, we will be happy to assist you soon.