I’ve been building a Power Automate flow that ingests large CSV files (5,000+ rows) and transforms them into structured Excel tables using Office Scripts. My original script parsed the CSV and wrote rows one-by-one, then applied removeDuplicates
, AutoFilter
, and table creation directly in the workbook.
This worked for small files but consistently failed for larger datasets with the error:
The Run script action in Power Automate has a ~120-second synchronous timeout, and my script was hitting that limit due to excessive workbook I/O.504 BadGateway Your Office Script has timed out. Please try again.
Has anyone solved this problem or can share best practices for optimizing Office Scripts in Power Automate?
Range.setValues()
for bulk writes instead of per-cell updates.cellsPerBatch = 10,000
).getWorksheet("Sheet1")
)—avoid active-sheet APIs.getTables()
and addTable()
(no unsupported async calls).