PyN*_*bie 4 python automation object
我有一组宏,我已经在excel中变成了一个加载项.这些宏允许我与另一个具有所谓的Microsoft Automation Objects的程序进行交互,这些程序可以控制其他程序的功能.例如,我在加载项中有一个过滤工具,用于过滤其他程序提供的列表以匹配Excel工作簿中的列表.这虽然很慢.我可能在另一个程序中有五万行,并希望过滤掉所有与Excel中三千行列表不匹配的行.这种匹配大约需要30-40分钟.我已经开始想知道是否有办法用Python做这件事,因为我怀疑匹配过程可以在几秒钟内完成.
编辑:
谢谢 - 基于看哈蒙德书的建议,我发现了一些资源.然而,虽然我仍然在探索它,但看起来很多都是旧的.例如,哈蒙德的书出版于2000年,这意味着写作大约在十年前完成.更正我刚刚发现了一个名为PyWin32的软件包,其版本为2/2009.
这应该让我开始.谢谢
Mar*_*tin 15
您可能需要win32com包.
这是我在http://www.markcarter.me.uk/computing/python/excel.html上找到的示例示例,其中显示了如何使用Excel与Excel.这可能是一个好的开始.
# this example starts Excel, creates a new workbook,
# puts some text in the first and second cell
# closes the workbook without saving the changes
# and closes Excel. This happens really fast, so
# you may want to comment out some lines and add them
# back in one at a time ... or do the commands interactively
from win32com.client import Dispatch
xlApp = Dispatch("Excel.Application")
xlApp.Visible = 1
xlApp.Workbooks.Add()
xlApp.ActiveSheet.Cells(1,1).Value = 'Python Rules!'
xlApp.ActiveWorkbook.ActiveSheet.Cells(1,2).Value = 'Python Rules 2!'
xlApp.ActiveWorkbook.Close(SaveChanges=0) # see note 1
xlApp.Quit()
xlApp.Visible = 0 # see note 2
del xlApp
# raw_input("press Enter ...")
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8201 次 |
| 最近记录: |