How to dynamically parse Excel attachments with variable column positions into a custom table?

rah dev
Tera Contributor

Hi Everyone,
I have a requirement to parse incoming Excel attachments and map the data into a custom table, but the Excel file structure is completely dynamic.
The Scenario:

1. Excel files are received via email and attached to specific Case records.
2. The column positions in the Excel sheet change constantly. For example, the data for a specific field might be in Column 1 in one file, Column 3 in another, or Column 5 in a different file.

Since the column layout shifts and is not fixed, a standard Data Source and Transform Map approach will not work.
My Questions:

1. What is the best practice or recommended scripting approach to parse Excel files dynamically based on Header Names rather than fixed column index positions?
2. Which platform component should be used to trigger this script automatically as soon as the file is attached to the Case record (e.g., Async Business Rule on sys_attachment, Flow Designer, or a Scripted REST API)?
3. If anyone has a working code snippet or script example using GlideExcelParser or any other API that handles shifting columns dynamically, could you please share it?

Any advice, code examples, or edge cases to consider would be highly appreciated.
Thanks in advance!

2 REPLIES 2

Ankur Bawiskar
Tera Patron

@rah dev 

ServiceNow has OOTB ExcelParser API

explore that

How to populate Manager field(reference type) and effective date from excel sheet when using Glide ... 

GlideExcelParser - Scoped, Global 

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader

Tanushree Maiti
Tera Patron

Hi @rah dev 

 

Refer: https://www.servicenow.com/community/developer-forum/how-to-check-excel-headers-and-contents/m-p/284...

https://www.youtube.com/watch?v=yBblyrss-CA&t=23s

https://www.servicenow.com/community/developer-forum/syntax-help-parsing-excel-into-a-table/m-p/3026...

Please Accept the solution if it assisted you with your question & Mark this response as Helpful.
Regards
Tanushree Maiti
ServiceNow Technical Architect
LinkedIn: https://www.linkedin.com/in/tanushreemaiti
How To Parse Excel In ServiceNow? | GlideExcelParser Class In ServiceNow Enjoy the exclusive content - Our Blogs:- https://servicenowspectaculars.com/ ServiceNow Basics Tutorials: https://www.youtube.com/playlist?list=PLrmQ9R9YkZmvGlU6zRVvtwQVndoXkvP0O ServiceNow Tips & tricks: ...