开发者

Clipboard format for DOCX data

My Java application generates a document in DOCX format using DocX4J. I need to send it into clipboard to be pasted in Word. I know that Word will consume HTML, but I rather not convert DOCX to HTML (I am not sure if DocX4J supports it and I rather not loose any formatting). What clipboard format (in Java terms DataFlavor) can I use to send DO开发者_如何学PythonCX data to clipboard so Word will understand it?

I am doing a similar thing with OpenOffice document and for that I use

DataFlavor odtFlavor = new DataFlavor("application/x-openoffice-embed-source-xml;"+
    "representationclass=java.io.InputStream");

How should I represent the DOCX document itself? In case of OpenOffice ODT I pass the InputStream created from the ODT file.

I believe a similar question has been asked by David Thielen here: What are the clipboard formats for Microsoft Office where you can drop a chart? but there are no answers.


Worst case, docx4j can export to HTML, so you could do that.

Or you could use RTF. docx4j uses FOP to create PDF, so you could use the XSL FO output to create RTF (FOP can do that - your mileage may vary).

Not sure which of these will give you better quality. Possibly the HTML (though what happens to images?).

Or you could make a basic docx to RTF converter.

There may be a way to use the docx format.

If you copy from Word, and look at it in ClipSpy (binary available in the source download from CodeProject), you'll see "Embed Source" is the data as a docx in OLE.

how to reload saved "Embed Source" clipboard data? says you can write your own "Embed Source" by passing Clipboard.SetData a stream object

Seems to depend whether you want to copy/paste or drag/drop though. See further your link What are the clipboard formats for Microsoft Office where you can drop a chart? and http://social.msdn.microsoft.com/Forums/en/worddev/thread/84263fb9-61c2-424a-a294-a12f69fd6b1b

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜