To continue my post here : http://www.docx4java.org/forums/docx-java-f6/convert-a-html-file-into-one-column-of-docx-table-t1888.html?sid=9b7b2605f896ed74f148fbb7ee01e9f3 , I'm wondering if it's possible to add an AltChunk with in a table cell object? I have to the following example code now:
- Code: Select all
public class AltChunkAddOfTypeHtml {
private static ObjectFactory factory;
public static void main(String[] args) throws Exception {
WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage
.createPackage();
factory = Context.getWmlObjectFactory();
Tbl table = factory.createTbl();
Tr tableRow = factory.createTr();
Tc tableCell = factory.createTc();
tableCell.getContent().add(
wordMLPackage.getMainDocumentPart().createParagraphOfText(
"Field 1"));
tableRow.getContent().add(tableCell);
table.getContent().add(tableRow);
wordMLPackage.getMainDocumentPart().addObject(table);
String html = "<html><head><title>Import me</title></head><body><p>Hello World!</p></body></html>";
wordMLPackage.getMainDocumentPart().addAltChunk(AltChunkType.Html,
html.getBytes());
wordMLPackage.save(new java.io.File(System.getProperty("user.dir") + "/test.docx"));
}
}
How to add AltChunk into tableCell? Or is there other approach to do that? I want to insert a part of html code into a table cell in a docx file. Thanks.