How can I create an Excel file from a script in Servicenow?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-01-2021 11:25 AM
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
- 6,224 Views
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-02-2021 11:09 AM
What is the use case? Any list or report can natively be exported to Excel without any code.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-13-2021 06:16 AM
Hey Adam,
In our case, we're distributing a report to external users. However, the report has gotten too large to send via email, and the client doesn't want to have users login and export themselves.
We're considering using a script to create the csv/xlsx file and sending with an integration.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-16-2021 08:43 AM
Have you looked at using an export set? https://docs.servicenow.com/csh?version=latest&topicname=c_ExportSets
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-16-2021 10:25 AM
Yes - that seems to be almost exactly what we need. Unfortunately, they won't for us due to clustered MID servers 😕
Export sets are not supported on MID Servers in a cluster
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-05-2022 06:12 AM
It is elementary. When you save the file, choose to save it as an excel file. The only thing I don't like is that it can't be saved in Google Sheets. This platform is way better to work with because it is easier to share the field and has more possibilities to work with the data from tables. But this is not a big problem because Coupler.io will link google sheets to excel. So I can quickly transfer Microsoft Office data to Google Sheets. But it would be great if they added the feature for the files to be saved in Google Sheets.