2026-06-08 14:31:31 +07:00
|
|
|
|
namespace QWERTYkez.ExcelProcessor;
|
2026-06-05 15:58:03 +07:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Предоставляет типобезопасное представление высоты строки в Excel с поддержкой различных единиц измерения.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public readonly struct RowHeight(double points)
|
|
|
|
|
|
{
|
2026-06-19 15:06:40 +07:00
|
|
|
|
const double POINTS_PER_INCH = 72.0;
|
|
|
|
|
|
const double INCH_PER_CM = 1.0 / 2.54;
|
|
|
|
|
|
const double POINTS_PER_CM = POINTS_PER_INCH * INCH_PER_CM; // ≈ 28.3464566929
|
|
|
|
|
|
const double POINTS_PER_MM = POINTS_PER_CM / 10.0; // ≈ 2.83464566929
|
2026-06-05 15:58:03 +07:00
|
|
|
|
|
2026-06-19 15:06:40 +07:00
|
|
|
|
const double DXA_PER_POINT = 20.0; // 1 point = 20 dxa
|
|
|
|
|
|
const double POINTS_PER_DXA = 1.0 / DXA_PER_POINT;
|
2026-06-05 15:58:03 +07:00
|
|
|
|
|
|
|
|
|
|
/// <summary>Высота в пунктах (points).</summary>
|
|
|
|
|
|
public double Points { get; } = points;
|
|
|
|
|
|
|
|
|
|
|
|
public static RowHeight FromPoints(double points) => new(points);
|
|
|
|
|
|
public static RowHeight FromInch(double inch) => new(inch * POINTS_PER_INCH);
|
|
|
|
|
|
public static RowHeight FromDXA(double dxa) => new(dxa * POINTS_PER_DXA);
|
|
|
|
|
|
public static RowHeight FromCM(double cm) => new(cm * POINTS_PER_CM);
|
|
|
|
|
|
public static RowHeight FromMM(double mm) => new(mm * POINTS_PER_MM);
|
|
|
|
|
|
|
|
|
|
|
|
public double Inch => Points / POINTS_PER_INCH;
|
|
|
|
|
|
public double DXA => Points / POINTS_PER_DXA;
|
|
|
|
|
|
public double CM => Points / POINTS_PER_CM;
|
|
|
|
|
|
public double MM => Points / POINTS_PER_MM;
|
|
|
|
|
|
}
|