but it only changes the next row
I know I must be missing something
Thanks
Public Function TestDoc() As MemoryStream
Dim ms As New MemoryStream Dim license As Aspose.Words.License = New Aspose.Words.License
license.SetLicense("Aspose.Words.lic")
Dim doc As Document = New Document()
Dim builder As DocumentBuilder = New DocumentBuilder(doc)
builder.StartTable()
builder.CellFormat.Borders.LineStyle = LineStyle.Single
builder.CellFormat.Borders.LineWidth = 1
builder.InsertCell()
builder.RowFormat.Height = 500
builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Top
builder.Writeln("This is row 1 cell 1")
builder.InsertCell()
builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Bottom
builder.Writeln("This is row 1 cell 2")
builder.EndRow()
builder.RowFormat.Height = 100
builder.RowFormat.HeightRule = HeightRule.Exactly
builder.InsertCell()
builder.CellFormat.Orientation = TextOrientation.Upward
builder.Writeln("This is row 2 cell 1")
builder.InsertCell()
builder.CellFormat.Orientation = TextOrientation.Downward
builder.Writeln("This is row 2 cell 2")
builder.EndRow()
builder.EndTable()
doc.Save(ms, Aspose.Words.SaveFormat.Rtf)
Return ms
Hi Bill,
Thanks for your inquiry.
Your code actually does set the vertical cell alignment of the top row correctly, its just that the cell itself it set to fit content and is too short to notice the affects of the alignment. If you increase the row height for that row in MS Word you will see that it is actually appearing correctly.
I have made some changes to your code above to ensure the output is generated correctly like this.
Dim doc As New Document()
Dim ms As New MemoryStream Dim builder As DocumentBuilder = New DocumentBuilder(doc)
builder.StartTable()
builder.CellFormat.Borders.LineStyle = LineStyle.Single
builder.CellFormat.Borders.LineWidth = 1
builder.RowFormat.Height = 100
builder.RowFormat.HeightRule = HeightRule.Exactly
builder.InsertCell()
builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center
builder.Writeln("This is row 1 cell 1")
builder.InsertCell()
builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Bottom
builder.Writeln("This is row 1 cell 2")
builder.EndRow()
' Set alignment back to top again for next row
builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Top
builder.InsertCell()
builder.Writeln("This is row 2 cell 1")
builder.InsertCell()
builder.Writeln("This is row 2 cell 2")
builder.EndRow()
builder.EndTable()
doc.Save(ms, Aspose.Words.SaveFormat.Rtf)
If you have any further queries, please feel free to ask.
Thanks,