社区所有版块导航
Python
python开源   Django   Python   DjangoApp   pycharm  
DATA
docker   Elasticsearch  
aigc
aigc   chatgpt  
WEB开发
linux   MongoDB   Redis   DATABASE   NGINX   其他Web框架   web工具   zookeeper   tornado   NoSql   Bootstrap   js   peewee   Git   bottle   IE   MQ   Jquery  
机器学习
机器学习算法  
Python88.com
反馈   公告   社区推广  
产品
短视频  
印度
印度  
Py学习  »  Python

用gspread-python发送到谷歌表单的图像看起来很小

elias • 2 年前 • 1269 次点击  

gspread公司 . 我找不到适用于它的函数的文档 docs.gspread.org . 如下面的代码片段所示,我当前正在使用该命令

worksheet.append_row(['testpic.png', '=IMAGE(\"{}\")'.format(
    'https://raw.githubusercontent.com/eliasdon/picturetest/main/download.png')], value_input_option='USER_ENTERED')

但是附加的图片非常小,即使手动调整也无法调整大小,如所附图片所示

enter image description here

我在谷歌表单上找到了这本指南 enter image description here

worksheet.append_row(['IMAGE("https://www.google.com/images/srpr/logo3w.png", 4, 50, 100)'], value_input_option='USER_ENTERED')
worksheet.append_row(['IMAGE("https://www.google.com/images/srpr/logo3w.png", 4, 50, 100)'])

代码:

import gspread
from oauth2client.service_account import ServiceAccountCredentials

# google scope
scope = ["https://spreadsheets.google.com/feeds", 'https://www.googleapis.com/auth/spreadsheets',
         "https://www.googleapis.com/auth/drive.file", "https://www.googleapis.com/auth/drive"]

# read credentials from json
creds = ServiceAccountCredentials.from_json_keyfile_name("creds.json", scope)

# get access using creds
client = gspread.authorize(creds)

# open sheet
sheet = client.open("test")

# open worksheet witin sheet
worksheet = sheet.worksheet('check')

# append pic
worksheet.append_row(['testpic.png', '=IMAGE(\"{}\")'.format(
    'https://raw.githubusercontent.com/eliasdon/picturetest/main/download.png')], value_input_option='USER_ENTERED')

如何将图片发送到google sheets并使其缩放到原始大小或设置的尺寸(x,y)?

Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/137421
 
1269 次点击  
文章 [ 1 ]  |  最新文章 2 年前