I'm designing a program in python tkinter that displays information that's currently in an excel spreadsheet. Ideally, I'd like to be able to share this program without needing to share the excel book as well. Is it possible to import the excel book into the program to make the program independent of that excel file? Let me know if I can provide any more clarification. Thank you!
CodePudding user response:
You would need to assign the Excel file's content to a variable in your program to do so. I hope it isn't very large, but to make it easier I recommend:
- saving your Excel file to
.csv
format - read it from Pytho
- convert it to the data type you want (ex: string, list, ...)
- save it back to a
.txt
file.
Now just copy the content of your .txt
and assign that to a variable somewhere in your code.
Edit: what Alphy13 said is also a solution
CodePudding user response:
Typically its best to create an example workbook that you can share. Give it all of the right parameters and leave out the sensitive data, or fill it in with fake data.
You could also set all of the variables that come from the excel file to have a default value that only changes when the workbook is present. This can be the first step toward creating proper error handling for your program.