import openpyxl
import pandas as pd
wb = openpyxl.load_workbook('测试.xlsx')
#如果有多个模块可以读写excel文件,这里要指定engine,否则可能会报错
writer = pd.ExcelWriter('测试.xlsx',engine='openpyxl')
#没有下面这个语句的话excel表将完全被覆盖
writer.book = wb
df = pd.DataFrame(data_pd)
df.to_excel(writer,sheet_name = 'Sheet2',index = None)
writer.save()
writer.close()
原文链接:https://blog.csdn.net/bin083/article/details/97049424
pandas写入excel 不覆盖sheet
最新推荐文章于 2024-06-01 16:02:06 发布