Hello, how I can get styles from existing docx document?
I need compare styles in docx document and dotx tempalte...
At first I need get styles, thanx a lot for advice!
It is currently Tue Aug 04, 2026 7:10 am
News of ForumsSpreadsheetMLPackage pkg = SpreadsheetMLPackage.createPackage();
factory = Context.getsmlObjectFactory();
WorksheetPart sheet = pkg.createWorksheetPart(new PartName("/xl/worksheets/sheet1.xml"), "Test Dossier", 1);
//Extract from file styles.xml
URL furl = ExcelWriter.class.getResource("styles.xml");
File knownstyles = new File(furl.toURI());
JAXBContext jc = org.docx4j.jaxb.Context.jc;
Unmarshaller u = jc.createUnmarshaller();
u.setEventHandler(new org.docx4j.jaxb.JaxbValidationEventHandler());
Styles styles = (Styles) u.unmarshal(knownstyles); //EXCEPTION THROWN HERE
pkg.addTargetPart(styles);WARN JaxbValidationEventHandler : [ERROR] : unexpected element (uri:"http://schemas.openxmlformats.org/wordprocessingml/2006/main", local:"body"). Expected elements are <{http://schemas.microsoft.com/office/2006/xmlPackage}body>,<{http://schemas.microsoft.com/office/2006/xmlPackage}background>
INFO JaxbValidationEventHandler : continuing (with possible element/attribute loss)cannot find symbol
[javac] symbol : class Logger
[javac] location: class org.docx4j.convert.in.Doc
[javac] private static Logger log = Logger.getLogger(Doc.class);
Total posts 10234 • Total topics 2888 • Total members 2109