I have two excel files. One file is a table of data and the other file is a coversheet containing some dates/descriptive information.
Is there a way, preferably using openpyxl, where I can combine these two files (data and coversheet) into a new excel file (final) with one sheet containing the coversheet and a second sheet containing the data. I need to retain the formatting of the coversheet.
I can copy one file to another row by row
import openpyxl as op
from openpyxl import Workbook
dest_wb = Workbook()
dest_wb.create_sheet("Cover Sheet")
dest_ws = dest_wb["Cover Sheet"]
source_wb = op.load_workbook(r"C:\Users\coversheet.xlsx")
source_sheet = source_wb.active
for row in source_sheet.rows:
for cell in row:
dest_ws[cell.coordinate] = cell.value
dest_wb.save(r"C:\Users\test.xlsx")
dest_wb.close()
source_wb.close()
But this doesn't retain any of the formatting from the original file