I need to insert a formula into Excel using Python. I am creating a dataframe and adding a column containing the formulas and then writing it into an Excel.
The formula has the format '=HYPERLINK("#'"&F2&"'!A1",F2)'
F2 is a variable and all other characters are constant. I need to dynamically generate this string.
I tried doing =HYPERLINK("#'"&F2&"'!A1",F2) but it is not working and I got '=HYPERLINK("#\'"&F2&"\'!A1",F2)' which includes the back slash and the formula does not work.
How do I create a string like '=HYPERLINK("#'"&F2&"'!A1",F2)' ?
Any help would be highly appreciated.
The method you used works with Python 3, i checked it with trinket.io