Enum CellsUnitType

CellsUnitType enumeration

Specifies the unit of measurement.

public enum CellsUnitType

Values

NameValueDescription
Pixel1Measurement is in pixels.
Point2Measurement is in points. A point represents 1/72 of an inch.
Inch4Measurement is in inches.
Cm6Measurement is in centimeters.
Character7In unit of characters.

Examples

namespace AsposeCellsExamples
{
    using Aspose.Cells;
    using System;

    public class CellsClassCellsUnitTypeDemo
    {
        public static void Run()
        {
            // Create a new workbook for demonstration
            Workbook workbook = new Workbook();
            Worksheet worksheet = workbook.Worksheets[0];

            try
            {
                // Demonstrate using different CellsUnitType enum values
                Console.WriteLine("Available CellsUnitType values:");

                // Display all enum values
                Console.WriteLine("Pixel: " + CellsUnitType.Pixel);
                Console.WriteLine("Point: " + CellsUnitType.Point);
                Console.WriteLine("Inch: " + CellsUnitType.Inch);
                Console.WriteLine("Cm: " + CellsUnitType.Cm);
                Console.WriteLine("Character: " + CellsUnitType.Character);

                // Example usage: Set column width using different units
                worksheet.Cells.SetColumnWidthPixel(0, 100); // Using Pixel unit
                worksheet.Cells.SetColumnWidthInch(1, 2.0);  // Using Inch unit

                // Save the workbook to demonstrate a complete flow
                workbook.Save("CellsUnitTypeDemo.xlsx");
                Console.WriteLine("Workbook saved successfully with different unit types applied.");
            }
            catch (Exception ex)
            {
                Console.WriteLine($"Error working with CellsUnitType: {ex.Message}");
            }
        }
    }
}

See Also