Oct-28-2022, 10:22 PM
(This post was last modified: Oct-29-2022, 06:03 AM by rob101.
Edit Reason: update
)
I've not used the openpyxl module, but I have been doing some reading on it, as I plan to use it, but from what I understand (and I could be wrong) I'd try something like:
I may even install the module and try it, so that I can see for myself what the issue is.
Okay, I've tried this:
Is that what you wanted?
Update:
Thinking about your code some more, the issue you have, is that in Python, the backslash is a 'special' character, as in
As you can see, that looks a little clumsy (as does all string concatenation), which is one reason not to use such code.
from openpyxl import Workbook wb = Workbook() sheet = wp.active sheet['A1'] = f"{=name(parameter)}"... or something along those lines.
I may even install the module and try it, so that I can see for myself what the issue is.
Okay, I've tried this:
from openpyxl import Workbook wb = Workbook() sheet = wb.active sheet['A1'] = "'\=name(parameter)" wb.save("test.xlsx")... and
A1
shows as '\=name(parameter)
Is that what you wanted?
Update:
Thinking about your code some more, the issue you have, is that in Python, the backslash is a 'special' character, as in
\t
for a tab. or \n
for a newline. If you want a literal backslash, you need to escape it, which is yet another use for backslash, so your code would need to be sheet.cell(1, 1).value = "\\'" + "=" + "name" + "(parameter)"
.As you can see, that looks a little clumsy (as does all string concatenation), which is one reason not to use such code.
Sig:
>>> import this
The UNIX philosophy: "Do one thing, and do it well."
"The danger of computers becoming like humans is not as great as the danger of humans becoming like computers." :~ Konrad Zuse
"Everything should be made as simple as possible, but not simpler." :~ Albert Einstein
>>> import this
The UNIX philosophy: "Do one thing, and do it well."
"The danger of computers becoming like humans is not as great as the danger of humans becoming like computers." :~ Konrad Zuse
"Everything should be made as simple as possible, but not simpler." :~ Albert Einstein