擅长:python、mysql、java
<p><strong>使用“xlsxwriter”作为引擎将解决问题</strong></p>
<p>您甚至不需要“if_sheet_exists=replace”,因为xlsxwriter将以任何方式进行替换,如果sheet不退出,它将创建一个</p>
<p><strong>这是一个工作示例</strong></p>
<pre class="lang-python prettyprint-override"><code>with pd.ExcelWriter(self.filename, engine="xlsxwriter") as writer:
self.df_holders.to_excel(writer, sheet_name='test')
</code></pre>