many debugs
All checks were successful
Publish NuGet packages / publish (push) Successful in 28s

This commit is contained in:
melekhin
2026-06-19 15:06:40 +07:00
parent 08b39b7bfe
commit e373d4108a
24 changed files with 1569 additions and 632 deletions

View File

@@ -13,7 +13,7 @@ public readonly struct CellFont : IEquatable<CellFont>
public string? FontFamily { get; init; }
/// <summary>Цвет текста.</summary>
public ExColor? FontColor { get; init; }
public System.Drawing.Color? FontColor { get; init; }
/// <summary>Жирное начертание.</summary>
public bool? IsBold { get; init; }
@@ -27,6 +27,35 @@ public readonly struct CellFont : IEquatable<CellFont>
/// <summary>Зачёркивание.</summary>
public bool? IsStrike { get; init; }
internal bool TryMerge(CellFont other, out CellFont result)
{
if (other.FontSize == FontSize &&
other.FontFamily == FontFamily &&
other.FontColor == FontColor &&
other.IsBold == IsBold &&
other.IsItalic == IsItalic &&
other.IsUnderline == IsUnderline &&
other.IsStrike == IsStrike)
{
result = default;
return false;
}
result = new CellFont
{
FontSize = other.FontSize ?? FontSize,
FontFamily = other.FontFamily ?? FontFamily,
FontColor = other.FontColor ?? FontColor,
IsBold = other.IsBold ?? IsBold,
IsItalic = other.IsItalic ?? IsItalic,
IsUnderline = other.IsUnderline ?? IsUnderline,
IsStrike = other.IsStrike ?? IsStrike
};
return true;
}
/// <summary>Создаёт элемент Font для Open XML.</summary>
public Font? ToFont()
{
@@ -39,11 +68,8 @@ public readonly struct CellFont : IEquatable<CellFont>
font.FontSize = new FontSize { Val = FontSize.Value };
if (FontFamily is not null)
font.FontName = new FontName { Val = FontFamily };
if (FontColor.HasValue && FontColor.Value.Color.HasValue)
{
var c = FontColor.Value.Color.Value;
if (FontColor is { } c)
font.Color = new Color { Rgb = $"{c.R:X2}{c.G:X2}{c.B:X2}" };
}
if (IsBold == true) font.Bold = new Bold();
if (IsItalic == true) font.Italic = new Italic();
if (IsUnderline == true) font.Underline = new Underline();
@@ -75,7 +101,7 @@ public readonly struct CellFont : IEquatable<CellFont>
Convert.ToByte(rgb.Substring(2, 2), 16),
Convert.ToByte(rgb.Substring(4, 2), 16)
);
result = result with { FontColor = new ExColor(color) };
result = result with { FontColor = color };
}
return result;
}