问题
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.
I can build a massive list of rows and add them easily using add_rows()
.
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).
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.
Is there any way at all so set child/parent relationships in python before ever communicating with the smartsheet server?
[Edit] 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.)
Thanks
回答1:
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.
You can either:
(1) Add all rows as a flat list, then indent each contiguous group of child rows. Repeat down the hierarchy.
(2) Add top level rows, then add each contiguous group of indented rows
来源:https://stackoverflow.com/questions/49416108/building-whole-sheet-programmatically-with-python-sdk