Pretty sure that this is not possible with free Java APIs. And I'm not going to list commercial stuff, nor am I going to Google it for you.
If OpenOffice (the tool) can do it then perhaps it can be done through the OpenOffice programming API. But then you'd have to check its documentation. But my initial gut reaction is: use .NET for this job. If it must be Java then perhaps there is some command line tool you can invoke through ProcessBuilder.