sysetr.blogg.se

Open office writer mail merge
Open office writer mail merge




open office writer mail merge

If that is the case then you could use the view cursor or enumerate text content. One more thought: getString() might just return an empty string if the entire document is in a table. tString(mergedText.getText().getString()) XText xText = (XText)xTextDocument.getText() XTextDocument xTextDocument = (XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, xComponent) XComponent xComponent = loader.loadComponentFromURL(url, "_blank", 0, new PropertyValue) Probably you intended to write something like this instead: XTextDocument mergedText = UnoRuntime.queryInterface(XTextDocument.class, mergedTextObject) These two lines would simply insert the text onto itself: XTextCursor cursor = mergedText.getText().createTextCursor()

Open office writer mail merge code#

Object mergedTextObject = job.execute(new NamedValue) Īnyway to me it looks like your code has a mistake in it. Did you start LO in headless mode? If not, then maybe the process needs a few seconds before it can display. However it sounds like you are not seeing a Writer window appear. If it is returning an XTextDocument, then normally I would assume the component is already open.

open office writer mail merge

However this code seems to show a working test. What version of LO are you using? The SHELL constant has only been around since LO 4.4, and it is not supported by Apache OpenOffice yet, so it could be that it isn't fully implemented. StoreMM.storeAsURL(outputDirectory + outputFilename, modelMM.getArgs()) XModel modelMM = UnoRuntime.queryInterface(XModel.class, mergedText) XStorable storeMM = UnoRuntime.queryInterface(XStorable.class, mergedText) If you want to save the result as a file you can do this mergedText.getCurrentController().getFrame().getContainerWindow().setVisible(true) The document opens as a new instance of a swriter document. I also don't need this line anymore loader.loadComponentFromURL("private:factory/swriter", "_blank", 0, new PropertyValue) The last line of code made the window appear with the filled mail merge result. MergedText.getCurrentController().getFrame().getContainerWindow().setVisible(true) The relevant snippets are these XJob job = UnoRuntime.queryInterface(XJob.class, mailMergeService) Hey guys I've found a simple way to open the result of my mail merge process directly.

open office writer mail merge

But this is not what my application should do.ĭoes someone know how I can open the result of the mail merge directly in an new writer document without saving the result to the hard drive? When I change the OutputType to MailMergeType.FILE the result is generated in a given directory and I can open the file and see that the mail merge succeeded. I guess I have to pass the XTextDocument component to the url-argument of the loadComponentFromURL method but I didnt find the right way to do that. XTextCursor cursor = mergedText.getText().createTextCursor() ĬtString(mergedText.getText().getString()) XTextDocument mergedText = UnoRuntime.queryInterface(XTextDocument.class, mergedTextObject) Loader.loadComponentFromURL(url, "_blank", 0, new PropertyValue) Object mergedTextObject = job.execute(new NamedValue) So I've tried something like this XJob job = UnoRuntime.queryInterface(XJob.class, mailMergeService) The successful mail marge returns a XTextDocument based component." The mmOutputType is set as MailMergeType.SHELL tPropertyValue("SaveAsSingleFile", mmSaveAsSingleFile) tPropertyValue("FileNamePrefix", mmFileNamePrefix) tPropertyValue("OutputURL", templateDirectory) tPropertyValue("OutputType", mmOutputType) tPropertyValue("CommandType", mmCommandType) tPropertyValue("DataSourceName", dbName) tPropertyValue("DocumentURL", templatePath) XPropertySet mmProperties = UnoRuntime.queryInterface(XPropertySet.class, mailMergeService) Object mailMergeService = mcf.createInstanceWithContext(mailMergePackage, context) I need help with opening the result of my mail merge operations directly in an new writer document.






Open office writer mail merge