feat(ExcelIO): add ColumnBuilder fluent API

This commit is contained in:
Joseph Doherty
2026-01-06 23:22:56 -05:00
parent 6c58394640
commit 48180259d2
@@ -0,0 +1,52 @@
namespace JdeScoping.ExcelIO.Mapping;
/// <summary>
/// Fluent builder for configuring Excel column properties.
/// </summary>
/// <typeparam name="T">The model type being mapped.</typeparam>
/// <typeparam name="TProperty">The property type.</typeparam>
public sealed class ColumnBuilder<T, TProperty>
{
private readonly ColumnDefinition _definition;
internal ColumnBuilder(ColumnDefinition definition)
{
_definition = definition;
}
/// <summary>Sets the column display order.</summary>
public ColumnBuilder<T, TProperty> Order(int order)
{
_definition.Order = order;
return this;
}
/// <summary>Sets the column header text.</summary>
public ColumnBuilder<T, TProperty> Header(string text)
{
_definition.HeaderText = text;
return this;
}
/// <summary>Sets the Excel number format.</summary>
public ColumnBuilder<T, TProperty> Format(string format)
{
_definition.Format = format;
return this;
}
/// <summary>Sets a fixed column width (disables auto-width).</summary>
public ColumnBuilder<T, TProperty> Width(double width)
{
_definition.AutoWidth = false;
_definition.Width = width;
return this;
}
/// <summary>Enables text wrapping for the column.</summary>
public ColumnBuilder<T, TProperty> WrapText(bool wrap = true)
{
_definition.WrapText = wrap;
return this;
}
}