Enum TextAlignmentType

TextAlignmentType enumeration

Enumerates text alignment types.

public enum TextAlignmentType

Values

NameValueDescription
General1792Represents general text alignment.
Bottom528Represents bottom text alignment.
Center1802Represents center text alignment.
CenterAcross1286Represents center across text alignment.
Distributed807Represents distributed text alignment.
Fill1284Represents fill text alignment.
Justify1821Represents justify text alignment.
Left257Represents left text alignment.
Right259Represents right text alignment.
Top512Represents top text alignment.
JustifiedLow832Aligns the text with an adjusted kashida length for Arabic text.
ThaiDistributed896Distributes Thai text specially, because each character is treated as a word.

Examples

[C#]

namespace Demos
{
    using Aspose.Cells;
    using Aspose.Cells.Charts;
    using System;

    public class TextAlignmentTypeDemo
    {
        public static void TextAlignmentTypeExample()
        {
            // Create a new workbook
            Workbook workbook = new Workbook();

            // Add a new worksheet to the workbook
            Worksheet worksheet = workbook.Worksheets[0];

            // Add sample data to the worksheet
            worksheet.Cells["A1"].PutValue("Name");
            worksheet.Cells["A2"].PutValue("John");
            worksheet.Cells["A3"].PutValue("Jane");
            worksheet.Cells["A4"].PutValue("Doe");

            worksheet.Cells["B1"].PutValue("Score");
            worksheet.Cells["B2"].PutValue(85);
            worksheet.Cells["B3"].PutValue(90);
            worksheet.Cells["B4"].PutValue(78);

            // Add a comment to a cell
            Comment comment = worksheet.Comments[worksheet.Comments.Add("A1")];
            comment.Note = "This is a comment.";
            comment.TextHorizontalAlignment = TextAlignmentType.Center;
            comment.TextVerticalAlignment = TextAlignmentType.Top;

            // Add a chart to the worksheet
            int chartIndex = worksheet.Charts.Add(ChartType.Column, 5, 0, 15, 5);
            Chart chart = worksheet.Charts[chartIndex];

            // Set the chart data range
            chart.SetChartDataRange("A1:B4", true);

            // Customize the chart title
            chart.Title.Text = "Scores Chart";
            chart.Title.TextHorizontalAlignment = TextAlignmentType.Center;
            chart.Title.TextVerticalAlignment = TextAlignmentType.Top;

            // Save the workbook
            workbook.Save("TextAlignmentTypeExample.xlsx");

            // Output the results
            Console.WriteLine("Workbook saved successfully with text alignment settings.");
        }
    }
}

See Also