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.

Excel workbook

William08
Tera Contributor

Hi all,

 

Need a help can we write the cell or edit the cell in excel using GlideExcelParser if not by this is there is  a way we can achieve this?

 

Thanks 

1 ACCEPTED SOLUTION

Hi @William08 

To read the file as below


  var csvFileCount=0;
  var ritmGr=//Gr can be of any table where csv is present;
  var RITMsys_id= ritmGr.getUniqueValue();
  var gsa = new GlideSysAttachment();
  var agr = gsa.getAttachments('sc_req_item', RITMsys_id);
    var gsa1 = new GlideSysAttachment();
    var agr1 = gsa1.getAttachments('sc_req_item', RITMsys_id);
    while(agr1.next())
    {
      var bytesInFile = gsa.getBytes(agr1); // tablename, table sysID
      var originalContentsInFile = Packages.java.lang.String(bytesInFile); // originalContentsInFile
      originalContentsInFile = String(originalContentsInFile);            
      var fileData = originalContentsInFile.split('\n');
      var csvHeaders = fileData[0] ;
      var csvHeadersValues = csvHeaders.split(','); //"," is the delimiter
      gs.info(fileData)
        gs.info(csvHeaders )
    }
 

Thanks and Regards,

Saurabh Gupta

View solution in original post

5 REPLIES 5

Thanks @Saurabh Gupta