Skip to main content

Notifications

Community site session details

Community site session details

Session Id :

One Minute Fixes - Clear an Excel Table

wyattdave Profile Picture wyattdave 406 Super User 2025 Season 1
When it comes to resetting Excel table you have 2 options, delete the table and create a new one, or delete each row individually. Because Power Automate interacts with Excel through the Excel API, that means every row interaction is a API call, which means the latter can be slow and burn through your daily Power Platform API allowance.

Luckily there are actually 3 ways, and that's to leverage a Office Script. But even that can sometimes timeout, unless you use the right delete function. The below script can delete thousands of rows in seconds, simply pass the table name in the action.






function main(workbook: ExcelScript.Workbook, sTable:string) {
	let table = workbook.getTable(sTable);
	let fRow=table.getRowCount();
	if (fRow>0){
		table.getRangeBetweenHeaderAndTotal().delete(0);
	}
}

Its super simple, getting the table from the table name input, checking to see if it has any rows, if it doe it deletes in one action (table.getRangeBetweenHeaderAndTotal().delete(0);). This action is the optimum way to delete rows in a Office Script. 

Comments