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

Viewed 3384

I need to take a screen shot of a specific range (eg: B2:Z15) in a Google sheet whenever the value in a specific cell (eg A1) changes - using Python.

The product has to be an image file saved from the capture. Not sure which library can do this. Thanks for help.

1 Answers

I'm just going to focus on grabbing a snapshot of the Google Sheet as you requested in your comments. I did some research and discovered a Python module called pyscreenshot. The screen coordinates in pyscreenshot.grab are from my system, so they have to be modified for your system.

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")

The image below shows a capture of cells B1:Z15. You can capture any visible location in the Google Sheet by modifying the values x1, x2, y1, y2.

enter image description here

Related