A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data
This is by design in custom xl() function. Hope Microsoft will add more custom function for Python Excel.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
When I hard code this,
a = xl("A1")
Python under Excel works fine. When I code this instead,
c = "A1"
a = xl(c)
I get this error
KeyError: 'A1'
Frustrating.
A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data
Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.
Answer accepted by question author
This is by design in custom xl() function. Hope Microsoft will add more custom function for Python Excel.
I think this is related to the way xl() and Python integration has been implemented. It appears there is some sort of preprocessing of the xl() function, i.e. all the xl() function calls are resolved before the rest of the Python code is executed. This implies the Python code must be "read-only' and as such cannot update Excel cell contents due to the preprocessing design constraint. Two gotcha's for the price of one design snafu,
I have to say, I struggle a bit with this. Seems like a string should be a string. I have several tables and would like to load them by using variable names. I also have a bunch of assumptions and would like to load them in a loop. If a string is not a string, then these approaches, like the OP's, just won't work. It also introduces a required level of hard-coding, which is bad in Excel and worse in programming, IMHO.
Thank you, when will this be fixed?
Also, I couldn't find the refence documentation you've so kindly listed. Presumably it was placed somewhere obvious by the Vogon planning department of Alpha Centauri. Nonetheless a link to it would be awesome.