How to add headers to excel dynamically using pandas

Experts,

I have one JSON file, and I want to convert the JSON data to excel directly.

What I have implemented so far is
image
by using
data = dict
df = pd.DataFrame(data)
df.to_excel(writer, sheet_name=‘each runs counts’, startrow=start_row, index=False, header=False)

Please note here, the data (dictionary) is not fixed, it might add more fields(keys, values), in this way, the excel might display as follows, which has added value, but the add keys are not displayed as the headers

If I want to adjust the key:value to header:value dynamically, I have to use
df.to_excel(writer, sheet_name=‘each runs counts’, startrow=start_row, index=False, header=header_list). However, the excel will display like the following:


This is actually not the way I want the excel to display.

What I want to achieve is that the headers only displayed on the first row, and the headers can extend dynamically by each run of the program as the data extend.

Could you please give some suggestions?