Java Open Office Portable
XStorable storable = (XStorable) UnoRuntime.queryInterface(XStorable.class, document); PropertyValue[] saveProps = new PropertyValue[0]; storable.storeAsURL("file:///C:/output/myfile.odt", saveProps);
// Example: Inserting text into a cell in OCalc XText xText = (XText) UnoRuntime.queryInterface(XText.class, cell); XTextCursor xTextCursor = xText.createTextCursor(); xText.insertString(xTextCursor, "Hello Open Office!", false); Use code with caution. Source: My IT Notes Best Practices for Developers The Apache OpenOffice API Project java open office
Using JODConverter , converting a file is straightforward and avoids much of the boilerplate UNO code: XStorable storable = (XStorable) UnoRuntime
public class CreateDocument public static void main(String[] args) try // Get the component context XComponentContext context = UnoRuntime.queryInterface(XComponentContext.class, "office:")); PropertyValue[] saveProps = new PropertyValue[0]
: In professional environments, Java is often used to script automated letter generation or integrate document data directly into SQL databases.