- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
Hello Everyone,
Explanation - Parse.xlsx (Example filename) formatted Excel files and access file data in the script.
The GlideExcelParser methods can be used in global and scoped scripts. Use the sn_impex namespace identifier to create a GlideExcelParser object.
GlideExcelParser()
Creates an instance of GlideExcelParser.
The API namespace identifier “sn_impex” must be used when creating a GlideExcelParser object.
Example —
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 my content helped you in anyway, please mark this content as BOOKMARK, SUBSCRIBE & HELPFUL
Best Regards,
Prashant Kumar (LearnIT)
YouTube Channel LearnIT: https://www.youtube.com/@learnitwithprashant
Blog LearnIT: https://medium.com/@LearnITbyPrashant
Prashant Kumar LinkedIn: https://www.linkedin.com/in/learnitbyprashant/
ServiceNow Community Prashant Kumar - https://www.servicenow.com/community/user/viewprofilepage/user-id/19635
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.