I'm trying to generate a xls custom file through script and attach it to a record.
It works fine when I use csv extension but when I change into xls or xlsx the file will be corrupted once I downloaded it from attachment.
Is there any way to achieve this through script?
EDIT: This is my sample script when I attach the file to a record:
`
var grRec = new GlideRecord("table");
grRec.addQuery("sys_id", sys_id);
grRec.query();
if (grRec.next()) {
var grAttachment = new GlideSysAttachment();
grAttachment.write(grRec, "test.xls", 'application/xls', xlsData);
}
`