logo

NJP

ServiceNow Things to Know 92: GlideExcelParser - Scoped, Global

Import · Jan 24, 2024 · article

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.

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();

parser.parse(attachmentStream);

//retrieve the column headersvar 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 columnsgs.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

View original source

https://www.servicenow.com/community/developer-blog/servicenow-things-to-know-92-glideexcelparser-scoped-global/ba-p/2802826