, ladies and gentlemen, there is a table (sheet1) because of the variable amount of data (that is, the number of rows), want to automatically add a line in the end of the data in the table as "total order:", "revenue total amount (RMB) :", "orders: total failure", the content of the "total number of treatment success", to consult and implementation?
The code is as follows:
The from openpyxl import load_workbook
The import pandas as pd
The import numpy as np
The from openpyxl. Utils. Dataframe import dataframe_to_rows
# write data
Datatotal1=pd. DataFrame ([" total order: ", "revenue total amount (RMB) :", "orders: total failure", "total treatment success"])
Df. Append (datatotal1, ignore_index=True)
Df. To_excel (writer, sheet_name='sheet1', startcol=0, while the startrow=0, the index=False, the header=True)
Wbsheet=the book [' sheet1]
Namelist='sheet1'
writer.save()