I create a table and add content using the builder (see below).
Due to the way everything is setup I first create the table and apply formatting afterwards including column width and row height.
Is there a way to resize an image in a cell after creating the table (retrieve shape from cell and resize it)?
Or is there a way to resize an image in a cell based on the column width (before knowing the column width so something like auto size).
this.builder = builder;
this.table = this.builder.startTable();
(loop) setCellValue( row, column, value)
this.table = this.builder.endTable();
I hope you can help me with this.
doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.RowFormat.Height = 250;
builder.CellFormat.Width = 400;
Shape shape = builder.InsertImage(@"C:\Temp\Sample.png", -1, -1);
Cell c = shape.GetAncestor(NodeType.Cell) as Cell;
shape.Width = c.CellFormat.Width;
shape.Height = c.ParentRow.RowFormat.Height;
That is a very good start
I have more than one cell with a shape and I know the location of the cells.
1. Can I retrieve the Shape from the cell (basically the other way around from what you do)?
or would it be easier/better to:
2. Store references to the Shape and loop through an array of them?
Thanks again for your prompt and very good help!
Marcel:1. Can I retrieve the Shape from the cell (basically the other way around from what you do)?
Table tab = doc.getFirstSection().getBody().getTables().get(0);
Cell cell = tab.getFirstRow().getFirstCell();
NodeCollection shapes = cell.getChildNodes(NodeType.SHAPE, true);
Is there a way to find the column width or row height without setting a (default) value?