如何使用python获取文件夹中的工作表ID数组 [英] How to get the array of sheet ids in a folder with python

查看:20
本文介绍了如何使用python获取文件夹中的工作表ID数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试从 get.folder() 调用中获取 id 数组时(通过使用 folder = folder.sheets.id),我得到答案:AttributeError: 'TypedList' object has no attribute 'id'"我不确定在 python 中调用什么函数来获取文件夹中的工作表 ID 数组.

When I try to get the id array from the get.folder() call (by using folder = folder.sheets.id), I get the answer: "AttributeError: 'TypedList' object has no attribute 'id'" I'm not sure what function to call in python to get the array of sheet ids in the folder.

我正在尝试使用 python smartsheet sdk 执行此操作,但我不确定如何对其进行格式化.

I am trying to do this with the python smartsheet sdk, but I am not sure exactly how to format it.

inc_list = ['all'] # you can add other parameters here, separated by a comma
 response = ss_client.Folders.copy_folder(
  folderID,                           # folder_id
  ss_client.models.ContainerDestination({
    'destination_id': destinationID,
    'destination_type': 'folder',
    'new_name': cellValue
  }),
include=inc_list
)

copiedFolderID = response.result.id

folder = ss_client.Folders.get_folder(
  copiedFolderID)       # folder_id 

newFolder = folder.sheets.id

print (newFolder)

也感谢您帮助回答我的问题,我真的很感激.

Also thanks for helping answer my questions, I really appreciate it.

推荐答案

folder.sheets 是一个数组.您收到错误的原因是数组级别没有 id 属性 - 您需要查看数组中的各个元素.

folder.sheets is an array. The reason you're getting an error is because there is no id attribute at the array level - you need to look at the individual elements inside the array.

查看 API 文档 以获取您将收到的示例.

Take a look at the API docs to get an example of what you'd receive.

sheet_ids = []
for sheet in folder.sheets
    sheet_ids.append(sheet.id)
print(sheet_ids)

这篇关于如何使用python获取文件夹中的工作表ID数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆