写入打开的Excel文件 [英] Writing to an open excel file
本文介绍了写入打开的Excel文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想写一个打开的Excel工作表.我是这样做的:
I want to write to an open excel sheet. I did this:
import win32com.client
app = win32com.client.GetActiveObject("Excel.Application")
但出现错误:
AttributeError: module 'win32com.gen_py.00020813-0000-0000-C000-000000000046x0x1x9'
has no attribute 'CLSIDToClassMap'
有人可以帮忙吗?
推荐答案
我建议为此使用pandas库:
I suggest using pandas library for this:
例如
import pandas as pd
df1 = pd.DataFrame([['a', 'b'], ['c', 'd']],
index=['row 1', 'row 2'],
columns=['col 1', 'col 2'])
df1.to_excel("output.xlsx")
这篇关于写入打开的Excel文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文