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

Jeffrey Siegel
Mega Sage

I have a similar need, have you been able how to generate a proper .xls from script? i can only generate a .csv but would prefer an .xls.

any solution to get in XLSX format?

Hello,

 

Were you able to achieve this? if yes please provide a solution you have used.

 

Thanks in advcance.

socialevil
Giga Contributor

I have a similar need, have you been able how to generate a proper .xls from script? i can only generate a .csv with wps office mod apk but would prefer an .xls.