Excel worksheet in servicenow
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-16-2023 09:25 AM - edited 06-16-2023 09:26 AM
Hi, this is more of an open question.
I've seen a few videos flying around where people are working on excel worksheets within the servicenow platform. I've done some research and found a couple of dev companies are offering this as an add on such as flaredev.io.
My question is... Is there anything native in servicenow where you could build this into your instance yourself?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2023 10:00 AM
Hi @Andrew18 ,
please refer https://developer.servicenow.com/dev.do#!/reference/api/rome/server/sn_impex-namespace/GlideExcelPar...
GlideExcelParserScopedAPI API within the sn_impex namespace, which allows you to parse Excel files in ServiceNow.
The GlideExcelParserScopedAPI provides methods that allow you to extract data from Excel worksheets, retrieve table information, and perform various operations on Excel data. This API is specifically designed for parsing Excel files within ServiceNow.
Here's an example of how you can use the GlideExcelParserScopedAPI to parse an Excel file and retrieve table information:
var parser = new sn_impex.GlideExcelParserScopedAPI();
var excelFile = new GlideSysAttachment().getContentStream(attachmentSysID); // Replace attachmentSysID with the sys_id of the Excel file attachment
var tableInfo = parser.getTableInfo(excelFile);
var worksheets = tableInfo.getWorksheets();
// Iterate over each worksheet and retrieve the data
for (var i = 0; i < worksheets.size(); i++) {
var worksheet = worksheets.get(i);
var worksheetName = worksheet.getName();
var rows = worksheet.getRows();
gs.info('Worksheet: ' + worksheetName);
// Iterate over each row and retrieve the cell values
for (var j = 0; j < rows.size(); j++) {
var row = rows.get(j);
var cells = row.getCells();
var rowData = [];
for (var k = 0; k < cells.size(); k++) {
var cell = cells.get(k);
var cellValue = cell.getValue();
rowData.push(cellValue);
}
gs.info('Row ' + (j + 1) + ': ' + rowData.join(', '));
}
}
Please note that the GlideExcelParserScopedAPI is available starting from the Rome release in ServiceNow.
Thanks,
Ratnakar
