Hi Alexey,
Am having an issue with having to centre align the shapes horizontally on table cells. Attached is what I am trying to achieve and below is the code. Could you please suggest changes.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
Table tblTemp = builder.StartTable();
builder.CellFormat.Borders.LineStyle = LineStyle.Dot;
builder.CellFormat.Borders.Color = Color.LightGray;
builder.CellFormat.TopPadding = 1.5;
builder.CellFormat.BottomPadding = 1.5;
builder.RowFormat.Height = 40;
builder.RowFormat.Alignment = RowAlignment.Center;
for (int i = 0; i < 2; i++)
{
for (int j = 0; j < 5; j++)
{
builder.InsertCell();
if (i == 0 && j == 0)
{
builder.Write("Leadership");
}
if (i == 1 && j == 0)
{
builder.Write("Team Fit");
}
if (i == 0 && j == 4)
{
Shape shape = new Shape(doc, ShapeType.Rectangle);
shape.FillColor =Color.SeaGreen;
shape.ZOrder = 1000;
shape.AnchorLocked = true;
shape.Height = 20;
shape.Width = 20;
shape.RelativeHorizontalPosition = RelativeHorizontalPosition.Column;
shape.HorizontalAlignment = Aspose.Words.Drawing.HorizontalAlignment.Center;
shape.RelativeVerticalPosition = RelativeVerticalPosition.Default;
shape.VerticalAlignment = VerticalAlignment.Center;
builder.InsertNode(shape);
}
if (j == 1)
{
Shape shpLine = new Shape(doc, ShapeType.Line);
shpLine.Width = 250;
builder.InsertNode(shpLine);
}
}
builder.EndRow();
}
builder.EndTable();
foreach (Row row in tblTemp.Rows)
{
foreach (Cell cell in row.Cells)
{
cell.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
if (cell.IsFirstCell)
{
cell.CellFormat.Width = 120.00;
cell.CellFormat.WrapText = true;
}
else
{
cell.CellFormat.Width = 67.00;
cell.CellFormat.WrapText = false;
cell.CellFormat.FitText = false;
}
}
}
doc.Save("C:\\Inetpub\\wwwroot\\Report Templates\\test.doc");