Create Excel Spreadsheet from script

r_t_bryan
Kilo Expert

I am attempting to run a background script to query a table, and put the results into a excel spreadsheet. I need to know if this is feasible from scripting and if so, what the best solutions would be.

Thanks in Advance,

Robert

11 REPLIES 11

Dave Smith1
ServiceNow Employee
ServiceNow Employee

Yes, it is feasible.



However, is it the best approach for what you want?   In my experience, most people wanting to export to Excel either wish to:


  • report on it
  • import it into another data source

- both of which are more easily achieved without Excel being part of the journey.



So... what's your end objective?


Hi Dave,



The concept is to write a background script which pulls all of the updates made to the system, within a certain period, within an update set, and put them into an excel spreadsheet for documentation purposes. Any Ideas?



Cheers,


Robert


Oops, I missed this response, sorry!



If it's updates, then possibly querying sys_update_xml.list to obtain the data (filtering for date ranges) and yanking that out ought to do the trick.   I'm not sure how you want the data presented, but it should be possible to expose this as a data feed to pull into another system for documentation (I know the XML could be translated into a report).



In terms of Excel... I believe it's possible to append a parameter to the end of the URL to view results as CSV, etc.   Excel spreadsheets aren't the best format for documentation, but if that's how it's to be stored then yup, it should be possible.


Hey there,



I've a similar request.



End objective:


Fixed format excel sheet containing values and counts from various tables. I.E. getting a list of users with a specific role per country: Find users with role, group by country, count them and then create a row in excel per country with that calculated amount, some values from the country table (code, name, etc), some fixed values (like "ServiceNow" in a "source" column).



The "Why":


Because another system will automatically process this excel. I don't have control over that system. They want this export in exact this format, whith the exact column names and everything. On a scheduled basis.



Problem:


How to create an excel like this? The only way I know would be to create a new table and list/view according to the required format, create those records via scheduled job and then use the ootb reporting/scheduled excel export. If possible, I would like to skip the "new table, new records" part. Is it?



Cheers,



Mike