Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Parse EXCEL file into JSON

soukayna
Tera Contributor

hello,

it is possible to parse an excel file into a json in script include .

if it s possible how we can do it.

thanks,

8 REPLIES 8

Andre Moreira
Kilo Expert

Hi Soukayna,



I'm curious about what problem are you trying to solve: could you share more details?



[]'s


Andre Moreira


hey andré,



i have a ui action that allow me to import data in my table, but before that i need to compare the header of the excel file with my table column to be sure that it's the corresponding file .


any ideas pls ?



thanks.


Hi Soukayna,



If it would have been csv then following code will give you attachment content in scoped app.


But this code won't work for xls or xlsx file.



var gr = new GlideRecord('sys_attachment');


gr.addQuery('sys_id', '8347eef44f330300fc11fa218110c722'); // give sys_id of attachment record


gr.query();


if (gr.next()) {


gs.info('Found Attachment.');


var ga = new GlideSysAttachment();


var content = ga.getContent(gr);


gs.info(content);


}



Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.


Thanks


Ankur


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

hey Ankur,



with csv it works but i need xsl/xlsx file and it doesn't work when i use the same code


any idea how to read xls / xlsx header file



thanks,