Convert Excel equation to Python equation for 2d list

时间:2017-11-13 06:15:57

标签: python excel python-2.7

I need to convert a string of Excel equation to a python code so it can bracket into a 2d list and give me the answer. In this scenario, the columns are named using a letter (A to Z) and rows are named (1 to 26). So, for example, what I have is:

list = [[1,1],
        [1,1]]

the string is:

my_str = "=A2 + 1"

and I need to convert it to:

list[1][0] + 1

or another example:

my_str = "=B2 + A2"

convert to:

list[1][1] + list[1][0]

Note that because of the way columns and rows are named, I need to switch the letter and the number, so A2 would be 2A and then [1][0].

I have spent hours trying to figure this out with no luck. any help would be appreciated. Thanks!

1 个答案:

答案 0 :(得分:0)

您需要某种知道如何将 Excel 映射到源代码中的变量的自动化工具(例如 X2C)。

相关问题