user189616
user189616

Reputation:

Adding content to ms word, Include macro

I have a JSP file to flush all data from database into a MS-Word document by setting the content-type keyword.

I need to add header and footer to the same document. I couldn't find a direct way from JSP without using APIs like POI. So I created a macro which works locally.

How do I add this to a dynamically generated Word file?

Upvotes: 0

Views: 983

Answers (2)

JasonPlutext
JasonPlutext

Reputation: 15863

I'd use POI or docx4j to create a docx file on the server, and add the header/footer as part of that process.

Upvotes: 0

Brian Agnew
Brian Agnew

Reputation: 272307

I had a similar problem with POI and Excel.

The solution is to manually create a template .doc file, with the macro present. Then in your code, load that document, amend it with your data, and save it. The macro will be preserved from the template document.

Upvotes: 1

Related Questions