Need help with excel attachment

Chinmayee1
Giga Contributor

Hi , I m trying to write an attachment to a record. If I do it with the below code its executing fine with csv format. but when I trying to write it using xlsx its not giving the report in the correct format. Is there any difference in the input format for xlsx?

var attach = new GlideSysAttachment();

var attachFile = attach.write(table object,filename,+".csv",application/csv,data); // prints fine

if I replace csv with xlsx it doesn't print in the correct format.I even tried using JSON name value pair but no luck.

Can anyone please advise ?

5 REPLIES 5

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

csv file is similar to plain text file so it would work.

There is no direct way to create data with Excel file and attach to record.

you might have to use custom approach

Office Templater Application

Generating customized csv or .xls file

Regards
Ankur

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

@Chinmayee 

Hope you are doing good.

Let me know if I have answered your question.

If so, please mark appropriate response as correct & helpful so that this thread can be closed and others can be benefited by this.

Regards
Ankur

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

@Chinmayee 

Hope you are doing good.

Did you get a chance to check on the links provided to resolve your query?

If your query is resolved please mark appropriate response as correct & helpful so that this thread can be closed and others can be benefited by this.

Regards
Ankur

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

Hope you are doing good.

Did you get a chance to check on the solution provided to resolve your query?

If your query is resolved please mark appropriate response as correct & helpful so that this thread can be closed and others can be benefited by this.

Regards
Ankur

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