绕过写数字到文件夹,但直接到excel

问题描述

目前我可以

  1. 在for循环中生成数字
  2. 将它们保存到目录plt.savefig
  3. 使用worksheet.insert_image将目录中的图像追加到具有df1,df2的现有excel中

我想跳过第2步,将生成的图像直接放入excel。这可能吗?

输入:

        writer = pd.ExcelWriter('test',engine='xlsxwriter')
            for i in range(.....shape[1]):
                plt.figure()
                fig,ax = plt.subplots(constrained_layout=True)
                .
                .
                .
                plt.savefig(f'{plot_l[i]}.jpg')
                plt.close()
    
        
        worksheet = workbook.add_worksheet(name='graphs')   
        .
        .
        .
        for i,image in enumerate(l):
            worksheet.insert_image(....)    
    
        df1.to_excel(writer,sheet_name='test1'...)
        df2.to_excel(writer,sheet_name='test2'...)

        workbook.close() 
        writer.save()

输出DuplicateWorksheetName: Sheetname 'plots',with case ignored,is already in use.

所需的输出: 擅长使用工作表test1test2plots

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)