use of org.xlsx4j.sml.CTLegacyDrawing in project Aspose.Cells-for-Java by aspose-cells.
the class Xlsx4jAddComments method addContent.
private static void addContent(WorksheetPart sheet) throws JAXBException, Docx4JException {
// Minimal content already present
SheetData sheetData = sheet.getContents().getSheetData();
// Now add
Row row = Context.getsmlObjectFactory().createRow();
Cell cell = Context.getsmlObjectFactory().createCell();
cell.setV("1234");
row.getC().add(cell);
row.getC().add(createCell("hello world!"));
sheetData.getRow().add(row);
// ADD A COMMENT TO CELL A1
CommentsPart cp = new CommentsPart();
cp.setContents(createComment("A1"));
sheet.addTargetPart(cp);
// Add <legacyDrawing r:id="rId1"/>
VMLPart vmlPart = new VMLPart();
// corresponds to A1
vmlPart.setContents(getVml(0, 0));
// you'll need extra VML for each comment
Relationship rel = sheet.addTargetPart(vmlPart);
CTLegacyDrawing legacyDrawing = Context.getsmlObjectFactory().createCTLegacyDrawing();
legacyDrawing.setId(rel.getId());
sheet.getContents().setLegacyDrawing(legacyDrawing);
}
Aggregations