python - Copy pandas dataframe to excel using openpyxl - Stack Overflow

PHOTO EMBED

Wed Jan 12 2022 00:24:17 GMT+0000 (Coordinated Universal Time)

Saved by [deleted user] #python

def create_sheet(sheet, df):

            # create rows generator, discarding index, header
            rows = dataframe_to_rows(df, index=False, header=False)

            # iterate throw row and col of df (specify starting coordinates of table to write)
            for r_idx, row in enumerate(rows, self.START_ROW):
                for c_idx, value in enumerate(row, self.START_COL):
                    sheet.cell(row=r_idx, column=c_idx, value=value)
content_copyCOPY

https://stackoverflow.com/questions/36657288/copy-pandas-dataframe-to-excel-using-openpyxl