Pick up a POI to export word http://www.cnblogs.com/xiufengd/p/4708680.html.
Public Static voidSetauto (xwpfdocument Doc)throwsSecurityException, Nosuchfieldexception, IllegalArgumentException, illegalaccessexception{List<POIXMLDocumentPart> list =doc.getrelations (); //set compatibility properties for some Word documents for(Poixmldocumentpart p:list) {if(pinstanceofxwpfsettings) {xwpfsettings Settings=(xwpfsettings) p; Field field= Settings.getclass (). Getdeclaredfield ("Ctsettings"); Field.setaccessible (true); //generates a new word set the object instance of the class ctsettings, sets the ultrailspace so that word underlines the space at the end of the lineCtsettings att =CTSettings.Factory.newInstance (); Att.addnewcompat (). Addnewultrailspace (). Setval (Stonoff.on);field.set (settings, ATT); Break; } } }
Set compatibility when POI exports word