Render_spreadsheet error


To download a spreadsheet I use a InputCellRange, but during rendering it gives a failure (TypeError: ‘InputCellRange’ object is not iterable). I’ve tried to start with the code from the examples on the SDK Reference, but they don’t seem to work with me. Could you help me out? This is my code and below the error message.



def download_spreadsheet(self, params, **kwargs):
    rates_updated_file = File.from_data(params.rates_updated)

    data = [
            [1, 2, 3],
            [4, 5, 6],
            ['a', 'b', 'c'],
    cell_range = InputCellRange('Object Type - Failure rates', left_column='B', top_row=3, data=data)
    template_path = Path(__file__).parent / 'Object Type Update.xlsx'
    with open(template_path, 'rb') as template:
        filled_spreadsheet = render_spreadsheet(template, cell_range)

    return DownloadResult(filled_spreadsheet, 'Object Type Update2.xlsx')

2022-06-14 16:27:26.928 ERROR : Exception is raised
Traceback (most recent call last):
File “viktor_connector\connector.pyx”, line 403, in connector.Job.execute
File “viktor\core.pyx”, line 1735, in viktor.core._handle_job
File “C:\Users\bart\viktor-apps\spreadsheet-test\app\calculation\”, line 201, in download_spreadsheet
filled_spreadsheet = render_spreadsheet(template, cell_range)
File “viktor\external\spreadsheet.pyx”, line 511, in viktor.external.spreadsheet.render_spreadsheet
File “viktor\external\spreadsheet.pyx”, line 527, in viktor.external.spreadsheet._create_fill_spreadsheet_request_body
TypeError: ‘InputCellRange’ object is not iterable

render_spreadsheet requires a list of cells (to be updated). So you would need:

        filled_spreadsheet = render_spreadsheet(template, [cell_range])
1 Like

Perfect! That’s it. Thanks for the quick respons!

1 Like