回答此问题可获得 20 贡献值,回答如果被采纳可获得 50 分。
<p>我正在尝试用excelwriter覆盖excel工作表。
但不会覆盖工作表,但会添加新工作表。(新工作表名称为test1、test11…)
下面是我的代码</p>
<pre><code> with pd.ExcelWriter(self.filename, mode='a', if_sheet_exists='replace', engine="openpyxl") as writer:
self.df_holders.to_excel(writer, sheet_name='test')
</code></pre>
<p>我的代码有问题吗</p>