I've got the following code to merge excel files. But it keeps losing the formatting. Is there any way to merge multiple excel files whilst retaining the cell formatting of each?
import numpy as np
import pandas as pd
import openpyxl
import os
import glob
all_names = []
for x in os.listdir(r'C:\<directory to excel files>'):
if x.endswith(".xlsx"):
all_names.append(x[:-5])
print(all_names)
all_data = pd.DataFrame()
for f in glob.glob("*.xlsx"):
df = pd.read_excel(f)
all_data = all_data.append(df,ignore_index=True)
appended_df = pd.concat((all_data), keys=(all_names))
appended_df.to_excel(r"C:\<directory for merged file>")