截屏 Google Sheet 或 Excel Python 中的范围?

Take screen shot of a range in Google Sheet or Excel in Python?

每当特定单元格(例如 A1)中的值发生变化时,我需要在 Google sheet 中截取特定范围(例如:B2:Z15)的屏幕截图 -使用 Python.

产品必须是从捕获中保存的图像文件。不确定哪个图书馆可以做到这一点。感谢您的帮助。

我将按照您在评论中的要求,专注于获取 Google Sheet 的快照。我做了一些研究并发现了一个名为 pyscreenshot 的 Python 模块。 pyscreenshot.grab中的屏幕坐标来自我的系统,因此必须针对您的系统进行修改。

import pyscreenshot

# im=pyscreenshot.grab(bbox=(x1,x2,y1,y2))
image = pyscreenshot.grab(bbox=(90, 240, 1500, 485))

# To view the screenshot
image.show()

# To save the screenshot 
image.save("screenshot_google_sheet_rows.png")

下图显示了对细胞的捕获 B1:Z15。您可以通过修改值 x1, x2, y1, y2.

捕获 Google Sheet 中的任何可见位置