How can I create an Excel file from a script in Servicenow?

mpsteve137
Tera Expert

I just need a really simple example of how I can create a .xlsx file not .csv. What is the syntax for this when writing with GlideSysAttachment().write?

I've tried:

var gsa = new GlideSysAttachment();

gsa.write(fixGr, 'test.xlsx', 'text/xlsx', data); 

but when I go to open the created attachment in Excel, Excel says its may be corrupted or the wrong file type. 
Can anyone please provide a simple example of what the data would look like and how to write it properly?

pls help

13 REPLIES 13

Prasad Pagar
Mega Sage

Hi,

Did you checked this?

https://community.servicenow.com/community?id=community_article&sys_id=35679790db1bcc90414eeeb5ca9619a7

https://community.servicenow.com/community?id=community_question&sys_id=575b0b21db9cdbc01dcaf3231f961955

Hope this helps

Thank you

Prasad

First, select the Automate tab on the ribbon. This will expose your two primary options in the Scripting Tools group: Record Actions and New Script. To create a new Office Script, press the Record Actions button, then start taking the steps you want to automate.

 

Regards,

Rachel Gomez

Paritosh
Giga Expert

hi,

you can try this ,

go through this link

 

Please mark this helpful

Thanks

Hey,

This link seems not available anymore.

If you are able to access it, please could you create a blog article?