- I can add html table in to the another word table' cell. (OK)
- I can generated last word document call lastDocument.docx (OK)
- I can not load again WordprocessingMLPackage.load(lastDocument.docx), throw this exception Docx4j unexpected element (uri:"http://schemas.openxmlformats.org/wordprocessingml/2006/main", local:"p") this is my code:
This code will be run
Tr workingRow = (Tr) XmlUtils.deepCopy(templateRow);
List<?> textElements = WMLPackageUtils.getTargetElements(workingRow, Text.class);
List<Tc> tcList = WMLPackageUtils.getTargetElements(workingRow, Tc.class);
Tc tc = WMLPackageUtils.getTc(tcList, "${Replace_Tex1}");
XHTMLImporterImpl XHTMLImporter = new XHTMLImporterImpl(wordMLPackage);
XHTMLImporter.setParagraphFormatting(FormattingOption.IGNORE_CLASS);
XHTMLImporter.setTableFormatting(FormattingOption.IGNORE_CLASS);
for (Object object : textElements) {
Text text = (Text) object;
if (!text.getValue().equals("${Replace_Tex1}"))
continue;
String replacementValue = (String) replacements.get(text.getValue());
//text.setValue(replacementValue);
R r = (R) text.getParent();
P paragraphOfText = wordMLPackage.getMainDocumentPart().createParagraphOfText("");
paragraphOfText.getContent().clear();
r.getContent().clear();eviewtable.getContent().add(new Tr(new Tc(itemTable, new Paragraph())));
tc.getContent().addAll(XHTMLImporter.convert(replacementValue, null));
tc.getContent().add(paragraphOfText);
No comments:
Post a Comment