Search code examples
javajspms-wordckeditor

Keep CKEditor formatting when exporting to MS Word


I'm trying to export a text area (for which I use ckeditor) into a Word document. I'm using JSP, and setting HTTP headers of a target page to receive the textarea value in request scope:

<%@page contentType="application/vnd.ms-word"%>
response.setHeader("Content-Disposition", "attachment;filename=responseLetter.doc")
...
<%=textAreaReqScopeValue%>

However, I lose formatting and style of my source ckeditor (example below) when the Word document has been generated:

<p>Dear Anonymous,</p><p>This is in response to your <strong><em><u>request regarding your continued ...

Is there any way to keep the formatting, either by generating the Word document or through CKEditor?


Solution

  • Using googoose.js or html-doc.js solved my problem. An open xml library should have been used to process html tags for the ms-word output.