Examples are as follows:
The import openpyxl
The import pandas as pd
Path=r "C: \ Users \ John \ Desktop \ test XLSX"
Df=pd read_excel (path, index_col=None)
Result=df. Head ()
Excel_writer=pd. ExcelWriter (path, engine='openpyxl')
Book=openpyxl. Load_workbook (excel_writer. Path)
Excel_writer. Book=the book
Result. To_excel (excel_writer=excel_writer, sheet_name='test', the index=None)
Excel_writer. Close ()
CodePudding user response:
You use python first file a copy not have replication methodCodePudding user response:
Book=load_workbook (tag_file) # to write the existing table
Writer=pd. ExcelWriter (tag_file, engine='openpyxl')
Writer.=the book book
Writer. Sheets=dict ((ws. The title, ws) for ws in the book. Worksheets)
Totaldata. To_excel (writer, sheet_name='company', startcol=0,
While the startrow=0, the index=True, the header=True) # header=False said don't header
Writer. The save ()
So I can write an existing table