Generating a word document with formatting

AnirudhKumar
Mega Sage
Mega Sage

I want to create a word document programmatically.

The code I'm using is shown below:

 

var inc = new GlideRecord("incident");
inc.addQuery("sys_id", "ede122932f8da5108d3fe36ef699b634");
inc.query();
if (inc.next()) {
   var gsa = new GlideSysAttachment();
  gsa.write(inc, 'test.doc', 'application/msword', '<h1>Test</h1>');	
}

 

The problem I have with this code is the formatting. When I open the system created word file, the HTML tags appear as string and are not rendered.

I remember this used to work earlier, what am I missing guys?

 

5 REPLIES 5

Hey @AnirudhKumar , what you need is to put: <table></table> tag at the begining and ending of your code. Ex: <table><h1>testing></h1></table>
This will work for all the code you want, you only need to put all inside <table> tags.

 

IDK why to be honest, but it worked for me. and if you need to declare CSS, you need to do it before <table> tag.

ex: <style>...all your CSS code...</style><table>...all your HTML code...</table>