Pd.ExcelWriter error: Append mode is not supported with xlsxwriter!

I want to add several pieces of data to an excel through Pandas. Check the document and find Pandas.ExcelWriter ( http://pandas.pydata.org/pand...) has this function, but if you need to append data to excel When using, set the parameter mode to "a" , so write the following program:

import pandas as pd                                                     

df = pd.DataFrame(data={"a":[4], "b":[""], "c":[0.5]})              

with pd.ExcelWriter("test.xlsx", mode="a") as writer: 
            df.to_excel(writer) 
            

where test.xlsx is an xlsx table with a, b, and c field names.
there was an error running the program:

ValueError                                Traceback (most recent call last)
<ipython-input-3-c643d22b4217> in <module>
----> 1 with pd.ExcelWriter("test.xlsx", mode="a") as writer:
      2     df.to_excel(writer)
      3 

~/anaconda/lib/python3.6/site-packages/pandas/io/excel.py in __init__(self, path, engine, date_format, datetime_format, mode, **engine_kwargs)
   1935 
   1936         if mode == "a":
-> 1937             raise ValueError("Append mode is not supported with xlsxwriter!")
   1938 
   1939         super(_XlsxWriter, self).__init__(path, engine=engine,

ValueError: Append mode is not supported with xlsxwriter!

but the official example is no different from what I wrote. I"m confused.

Jul.07,2022

change to:

with pd.ExcelWriter("test.xlsx", mode='a', engine="openpyxl") as writer: 
     df.to_excel(writer) 
Menu