以编程方式构建整个工作表

以编程方式构建整个工作表

本文介绍了使用 Python SDK 以编程方式构建整个工作表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从头开始构建整个工作表,并在执行过程中保持高效.为此,我试图依赖批量操作.

I'm trying to build a whole sheet from scratch, and stay efficient while doing it.For that purpose, I am trying to rely on bulk operations.

我可以构建大量行并使用 add_rows() 轻松添加它们.

I can build a massive list of rows and add them easily using add_rows().

但是,我需要一些行作为其他行的子行,并且 row.indentrow.parent_id 似乎都不可能在新行上设置(因为新行行还没有 ID).

However, I need some rows to be children of other rows, and neither row.indent nor row.parent_id seem possible to set on new rows (since the fresh rows don't have an id yet).

我可能:创建父行 > add_rows() > get_sheet() > 在工作表中找到行 ID > 创建子行 > add_rows() 但我失去了批量操作的好处.

I could possibly: create the parent row > add_rows() > get_sheet() > find the row id in sheet > create the child row > add_rows() but I'm losing the benefits of bulk operations.

在与 smartsheet 服务器通信之前,有没有什么办法可以在 python 中设置子/父关系?

Is there any way at all so set child/parent relationships in python before ever communicating with the smartsheet server?

或者,通过 SDK(或其他)导出 excel 文件的方法也可以使用,因为我现在可以使用 xlsxwrite 创建我的表格并手动将其上传到 smartsheet.(这不是一个选项,因为我们试图一天多次生成数十张工作表,必须使其自动化.)

Alternatively, a way to export an excel file via the SDK (or other) would also work, as I'm able to create my table with xlsxwrite and upload it manually to smartsheet at the moment. (Which is not an option, as we're trying to generate dozens of sheets, multiple times a day, got to automate it.)

谢谢

推荐答案

您无法在一次调用中创建具有层次结构的工作表.单个 POST 或 PUT 中的所有行必须具有相同的位置说明符.

You cannot create a sheet with hierarchy in a single call. All rows in a single POST or PUT must have the same location specifier.

您可以:

(1) 将所有行添加为一个平面列表,然后缩进每个连续的子行组.向下重复层次结构.

(1) Add all rows as a flat list, then indent each contiguous group of child rows. Repeat down the hierarchy.

(2) 添加顶级行,然后添加每组连续的缩进行

(2) Add top level rows, then add each contiguous group of indented rows

这篇关于使用 Python SDK 以编程方式构建整个工作表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 21:44