Office Script to delete all rows in a table receives timeout error

Wewillendure 0 Reputation points
2024-05-16T14:08:07.1333333+00:00

I have an office script that is designed to delete all rows in a table. When I run it for 50 or less rows it runs with no problem, but times out when I test it for a larger number of rows (~600). Once this project is live I anticipate the table will have over 9000 rows when it needs to be cleared once a week. The error I recieve when running the script manually is:

Line 6: Table deleteRowsAt: Timeout

I'd prefer this clearing happen as part of the pre-existing power-automate process, rather than a manual process. The power automate process creates a copy of the file in an archive folder (which is working correctly) and then runs the script to clear the table in the live file.

Note the timeout occurs both within power automate and when running the script in excel online was well.

My script is below:

function main(workbook: ExcelScript.Workbook) {
  let Submission_Table = workbook.getTable("Table1");

  //Count the number of rows in the table
  let rowCount = workbook.getTable("Table1").getRowCount()

  //Delete the rows in the submission table
  Submission_Table.deleteRowsAt(0, rowCount);
}

Is there a way I can improve the efficiency of the deletion or increase the timeout limit?

OS: Windows 11

Office: 365

Thank you in advance for your help.

Excel
Excel
A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data.
1,602 questions
Office Development
Office Development
Office: A suite of Microsoft productivity software that supports common business tasks, including word processing, email, presentations, and data management and analysis.Development: The process of researching, productizing, and refining new or existing technologies.
3,640 questions
0 comments No comments
{count} votes