Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

Parse Excel to JSON format

monikagmk12
Mega Contributor

I am trying to read an attachment file from a attachment variable to parse data in it and build a JSON payload per row with header as name and value as key to use that information on a variable. to make any progress , I cant get past the parser.parse line, not seeing any error too. testing below script in a fix script and then use it it in a client callable script include

 var jsonData = [];
 var attachmentSysId = '12f78a92938407509f98fa252603d6d6';
 gs.info('AttachmentSysId--->' + attachmentSysId);
 // Uses sn_impex namespace to parse attachment stream
 var parser = new sn_impex.GlideExcelParser();
 var attachmentStream = new GlideSysAttachment().getContentStream(attachmentSysId);
 gs.info('AttachmentStream--->' + attachmentStream);

 if (attachmentStream) {
     gs.info('AttachmentStreamExists');
     parser.parse(attachmentStream); //Data exists in the excel file and it has only 1 sheet and 1 row in that sheet exluding header
     while (parser.next()) {  
         // Collects row data into the JSON array
         gs.info('ParserExists');
         jsonData.push(parser.getRow());
     }
 }

 gs.info(JSON.stringify(jsonData));


Output:

*** Script: AttachmentSysId--->12f78a92938407509f98fa252603d6d6
*** Script: AttachmentStream--->com.glide.communications.GlideScriptableInputStream@74f0306d
*** Script: AttachmentStreamExists
*** Script: []

 

3 REPLIES 3

NagaChandaE
Mega Sage

Hi @monikagmk12 ,

Your script is working . I tested with a xl sheet . Just want to verify from which file type are you trying to extract the data? 

If it is .csv it won't work.

It is in XLSX as required.

can you post a image of the excel data you used for testing , google says it could be due to the data format of my file. However I am using files from our data sources to test which are imported successfully using Import sets previously.

Hi @monikagmk12 ,
Below is the image of xlsheet . The format is .xlsx

Screenshot 2026-04-08 at 11.36.49 AM.png