如何使用python从excel文本框中获取内容

时间:2016-07-14 03:36:22

标签: excel python-3.x textbox

enter image description here

我想使用python获取excel文本框的内容,但我没有解决方法,请帮帮我。

2 个答案:

答案 0 :(得分:0)

尝试使用 xlrd包

如果您还没有

,则需要使用 pip 进行安装
pip install xlrd 

python3 -m pip install xlrd

答案 1 :(得分:0)

在Windows计算机上,尝试使用pypiwin32软件包pip install pypiwin32

第一个工作表有一个带有文本“hello world”的文本框的示例:

>>> import win32com.client as win32
>>> excel = win32.gencache.EnsureDispatch('Excel.Application')
>>> excel.Visible = False
>>> wb = excel.Workbooks.Open("c:\hello.xlsx")
>>> sheet = wb.Worksheets(1)
>>> canvas = sheet.Shapes
>>> for shp in canvas:
...   print shp.TextFrame2.TextRange
...
hello world
>>>