how can i export data into excel [.xlsx] via script

snavuluri
Giga Contributor

Hi All,

 Please guide on,  how i can export data into excel [.xlsx] via script.

 

Regards,

Suresh.

1 ACCEPTED SOLUTION

@snavuluri 

we forgot adding the underscore

now it should work fine

g_navigation.open('/' + tableName + '_list.do?EXCEL&sysparm_view=ess', '_blank');

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

29 REPLIES 29

snavuluri
Giga Contributor

Hi Ankur,

       It is a generic/global task, normally from any table list,  we do right click and export in .xlsx. Instead of that activity, just need to do the export data using script. That script can later on will be use in button for or any other. For now let assume for incident list.

Regards,

Suresh. 

Hi,

then you can use this UI Action on your table

Type - List Banner button

Client Checkbox - true

Onclick - downloadRecords();

Script:

function downloadRecords(){

	var tableName = 'incident';
	g_navigation.open('/' + tableName + 'list.do?CSV&sysparm_view=ess', '_blank');
}

find_real_file.png

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

snavuluri
Giga Contributor

Hi Ankur,

     I am able to download into csv file but not getting the data export in excel.

 

Regards,

Suresh.

@snavuluri 

So did you use the script I mentioned or you are using some other script?

if other script please share that

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

snavuluri
Giga Contributor

Hi Ankur,

     Am using the same script as you mentioned. getting the export attackment with empty sheet without any data whick getting zero bytes.

find_real_file.png

 Regards,

Suresh.