I need to copy a cell to another one with all the styles associated, including the width dimension.
below a simple example (an instruction doesn't work):
import openpyxl
from copy import copy
src_wb = openpyxl.load_workbook("C:\\Users\\Admin\\Desktop\\database.xlsx")
src_ws = src_wb[src_wb.sheetnames[0]]
dst_wb = openpyxl.Workbook()
dst_ws = dst_wb.active
dst_ws.title = "TEST"
src_cell = src_ws.cell(row=1, column=1)
dst_cell = dst_ws.cell(row=1, column=1)
if src_cell.has_style:
dst_cell._style = copy(src_cell._style) # it doesn't work..
dst_cell.value = src_cell.value
dst_wb.save("test.xlsx")
dst_wb.close()
how can I fix the issue?