How to check Excel headers and contents
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-04-2024 08:31 PM
Hello, I am looking for a new Excel application.
We have a requirement to check the content of an Excel attached to a catalog item in our system.
I would like to parse the Excel attached to the catalog item and check that the correct template is used and that the content is correct.
How should I implement this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-04-2024 08:43 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-04-2024 08:50 PM
Hi @MiY ,
Best solution is to use GlideExcelParser to play with the data from an excel.
Please check below link for the entire class and its different methods.
https://developer.servicenow.com/dev.do#!/reference/api/quebec/server/GEPS-getRow
Adding the sample code for reference.
var parser = new sn_impex.GlideExcelParser(); var attachment = new GlideSysAttachment(); // use attachment sys id of an excel file var attachmentStream = attachment.getContentStream(<attachment sys id>); parser.parse(attachmentStream); //retrieve the column headers var headers = parser.getColumnHeaders(); var header1 = headers[0]; var header2 = headers[1]; //print headers gs.info(header1 + " " + header2); while(parser.next()) { var row = parser.getRow(); //print row value for both columns gs.info(row[header1] + ' ' + row[header2]) }
If I could help you with your Query then, please hit the Thumb Icon and mark it as Correct !!
Thanks & Regards,
Sumanth Meda