import openpyxl
import string
ses["writeable_excel"] = openpyxl.load_workbook("/path/to/Excel.xlsx")
ses["writeable_excel_active"] = ses["writeable_excel"].active
col1 = "Column 1"
col3 = "Column 3"
col6 = "Column 6"
excel_cols = list(string.ascii_uppercase)
database_cols = [col1, col3, col6]
# If copying col names fr a different Excel, make sure they are up-to-date
for col in range(0, len(database_cols)):
ses["writeable_excel_active"][excel_cols[col] + str(1)].value = database_cols[col] # .strip(), if some cells have whitespace, take it out so that it'll show as NaN
ses["writeable_excel"].save("/path/to/Excel.xlsx")
ses["writeable_excel_read"] = pd.read_excel("/path/to/Excel.xlsx", engine="openpyxl") # read written Excel
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter