Hello guys,
I have a couple of working python scripts to format excel that is working fine in VS. When I try to run them in alteryx python tool the excel files always get corrupted.
I tried to run it on Alteryx version 2024.1 and 2023.1 and the results are the same. Your help would be very appreciated!
Thank you
import openpyxl
# Make a new notebook (workbook)
workbook = openpyxl.Workbook()
# Open a page (sheet) in the notebook
sheet = workbook.active
# Write something on the page
sheet['A1'] = 'Hello'
sheet['B1'] = 'World'
# Save your notebook with a special name
workbook.save(PATH)
Solved! Go to Solution.
Do you have other tools in your Alteryx workflow?
@apathetichell yes I do, but I have just tried in a new workflow with only python tool I got the same result
Edit: I also tried in one drive and in my local machine
are you passing in anything to your python (like a path)?
@apathetichell I am just using a single python tool. it is frustrating because all my codes run on Visual Studio but on Alteryx they corrupt excel files.
If you mind testing, just change the path on the last line of code
thank you!
I'm on 2021.4 and successfully ran this with no errors. my next suggestion would be to try deleting the file and re-running? I have AMP on while running - which I never do - and it still created the file successfully.
One note - I ran this with Alteryx in admin mode (primarily to make sure the packages were successfully created in the pip install)...
@apathetichell Did your excel file get corrupted when you open it?
No. It was fine.
Question - are you publishing to Users - or your User name subfolder? Do you have any special characters/accents in your name?
I was getting this error using both pandas and openpyxl to create/edit an excel file. I upgraded the version of these libraries and the problem is solved.
@apathetichell Thank you for your help!