rainbow12
rainbow12

Reputation: 477

Combine several xlsx files into one single xlsx

I want to combine several xlsx files into one. However this xlsx files have different number of lines and they have highlight cells. When I combine them into one, they appear to be next, without a row beteween the two dataframes, and they also lost the highlighted cells.

Here is the code I have, so far:

writer=pd.ExcelWriter('output.xlsx')
# xlsfiles = [files_in for files_in in glob.glob('*.xlsx')]
for files_in in glob.glob('*.final_2.xlsx'):
    excel_file=pd.ExcelFile(files_in)
    df_excell=pd.read_excel(files_in)
    df_excell.to_excel(writer,index=False)
writer.save()

Thanks!

Upvotes: 0

Views: 54

Answers (1)

Jeff Coldplume
Jeff Coldplume

Reputation: 353

I would start by taking a look at a similar question a user has posted here:

Python Excel template read and re-write, maintaining formulae and formatting

Upvotes: 0

Related Questions