简体   繁体   English

使用 gspread acell 获取特定的工作表范围

[英]Get specific sheet range using gspread acell

I want to get specific sheet range which consists of multiple row for example:我想获得由多行组成的特定工作表范围,例如:

在此处输入图像描述

So my code is:所以我的代码是:

    work_book = sheet.get_worksheet(sheet_idx)
    row_value = work_book.acell('A1:C3').value
    print(row_value)

When I run the code I only get value from cell A1 (which is empty).当我运行代码时,我只从单元格A1 (为空)中获取值。 If I use A2:C3 , the result will be Hello .如果我使用A2:C3 ,结果将是Hello I expected it will show entire sheet range.我预计它将显示整个工作表范围。 Should I loop or something?我应该循环还是什么? Please assist.请协助。

acell only returns a single cell. acell只返回一个单元格。 For a range you should use get https://gspread.readthedocs.io/en/latest/api.html#gspread.models.Worksheet.get对于一个范围,您应该使用get https://gspread.readthedocs.io/en/latest/api.html#gspread.models.Worksheet.get

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM