HorizontalAlignment Enumeration |
Horizontal alignment.
Namespace: SautinSoft.DocumentAssembly: SautinSoft.Document (in SautinSoft.Document.dll) Version: 2025.2.13
Syntaxpublic enum HorizontalAlignment
Public Enumeration HorizontalAlignment
MembersMember name | Value | Description |
---|
Left | 0 |
Left alignment.
|
Center | 1 |
Centered alignment.
|
Right | 2 |
Right alignment.
|
Justify | 3 |
Justified alignment.
|
ExampleSee Developer Guide: Creates a table using DocumentBuilder
Creates a table using DocumentBuilder using C#
using System;
using SautinSoft.Document;
using SautinSoft.Document.Tables;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Example
{
class Program
{
static void Main(string[] args)
{
InsertingTable();
}
static void InsertingTable()
{
DocumentCore dc = new DocumentCore();
DocumentBuilder db = new DocumentBuilder(dc);
Table table = db.StartTable();
db.TableFormat.PreferredWidth = new TableWidth(LengthUnitConverter.Convert(5, LengthUnit.Inch, LengthUnit.Point), TableWidthUnit.Point);
db.CellFormat.Borders.SetBorders(MultipleBorderTypes.Outside, BorderStyle.Single, Color.Green, 1);
db.CellFormat.VerticalAlignment = VerticalAlignment.Top;
db.ParagraphFormat.Alignment = HorizontalAlignment.Center;
db.RowFormat.Height = new TableRowHeight(105f, HeightRule.Exact);
db.InsertCell();
db.Write("This is Row 1 Cell 1");
db.InsertCell();
db.Write("This is Row 1 Cell 2");
db.InsertCell();
db.Write("This is Row 1 Cell 3");
db.EndRow();
db.CellFormat.Borders.SetBorders(MultipleBorderTypes.Outside, BorderStyle.Single, Color.Black, 1);
db.CellFormat.VerticalAlignment = VerticalAlignment.Center;
db.ParagraphFormat.Alignment = HorizontalAlignment.Left;
db.RowFormat.Height = new TableRowHeight(150f, HeightRule.Exact);
db.InsertCell();
db.Write("This is Row 2 Cell 1");
db.InsertCell();
db.Write("This is Row 2 Cell 2");
db.InsertCell();
db.Write("This is Row 2 Cell 3");
db.EndRow();
db.CellFormat.Borders.SetBorders(MultipleBorderTypes.Outside, BorderStyle.Single, Color.Orange, 1);
db.CellFormat.VerticalAlignment = VerticalAlignment.Bottom;
db.ParagraphFormat.Alignment = HorizontalAlignment.Right;
db.RowFormat.Height = new TableRowHeight(125f, HeightRule.Exact);
db.InsertCell();
db.Write("This is Row 3 Cell 1");
db.InsertCell();
db.Write("This is Row 3 Cell 2");
db.InsertCell();
db.Write("This is Row 3 Cell 3");
db.EndRow();
db.EndTable();
string filePath = "Result.docx";
dc.Save(filePath);
System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(filePath) { UseShellExecute = true });
}
}
}
Creates a table using DocumentBuilder using VB.Net
Imports System
Imports SautinSoft.Document
Imports SautinSoft.Document.Tables
Imports System.Collections.Generic
Namespace Example
Friend Class Program
Shared Sub Main(ByVal args() As String)
InsertingTable()
End Sub
Private Shared Sub InsertingTable()
Dim dc As New DocumentCore()
Dim db As New DocumentBuilder(dc)
Dim table As Table = db.StartTable()
db.TableFormat.PreferredWidth = New TableWidth(LengthUnitConverter.Convert(5, LengthUnit.Inch, LengthUnit.Point), TableWidthUnit.Point)
db.CellFormat.Borders.SetBorders(MultipleBorderTypes.Outside, BorderStyle.Single, Color.Green, 1)
db.CellFormat.VerticalAlignment = VerticalAlignment.Top
db.ParagraphFormat.Alignment = HorizontalAlignment.Center
db.RowFormat.Height = New TableRowHeight(105.0F, HeightRule.Exact)
db.InsertCell()
db.Write("This is Row 1 Cell 1")
db.InsertCell()
db.Write("This is Row 1 Cell 2")
db.InsertCell()
db.Write("This is Row 1 Cell 3")
db.EndRow()
db.CellFormat.Borders.SetBorders(MultipleBorderTypes.Outside, BorderStyle.Single, Color.Black, 1)
db.CellFormat.VerticalAlignment = VerticalAlignment.Center
db.ParagraphFormat.Alignment = HorizontalAlignment.Left
db.RowFormat.Height = New TableRowHeight(150.0F, HeightRule.Exact)
db.InsertCell()
db.Write("This is Row 2 Cell 1")
db.InsertCell()
db.Write("This is Row 2 Cell 2")
db.InsertCell()
db.Write("This is Row 2 Cell 3")
db.EndRow()
db.CellFormat.Borders.SetBorders(MultipleBorderTypes.Outside, BorderStyle.Single, Color.Orange, 1)
db.CellFormat.VerticalAlignment = VerticalAlignment.Bottom
db.ParagraphFormat.Alignment = HorizontalAlignment.Right
db.RowFormat.Height = New TableRowHeight(125.0F, HeightRule.Exact)
db.InsertCell()
db.Write("This is Row 3 Cell 1")
db.InsertCell()
db.Write("This is Row 3 Cell 2")
db.InsertCell()
db.Write("This is Row 3 Cell 3")
db.EndRow()
db.EndTable()
Dim filePath As String = "Result.docx"
dc.Save(filePath)
System.Diagnostics.Process.Start(New System.Diagnostics.ProcessStartInfo(filePath) With {.UseShellExecute = True})
End Sub
End Class
End Namespace
See Also