using System;
namespace FlexFramework.Excel
{
///
/// Column mapping
///
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property, Inherited = false)]
public sealed class ColumnAttribute : Attribute
{
///
/// One-based column index
///
public int Column { get; private set; }
///
/// Default value when fallback
///
public object Default { get; private set; }
///
/// Enable fallback
///
public bool Fallback { get; private set; }
///
/// Mapping column
///
/// One-based column index
public ColumnAttribute(int column)
{
Column = column;
}
///
/// Mapping column
///
/// One-based column index
/// Fallback value
public ColumnAttribute(int column, object @default) : this(column)
{
Default = @default;
Fallback = true;
}
///
/// Mapping column
///
/// Column formula, e.g. A, AB
public ColumnAttribute(string column) : this(Address.ParseColumn(column))
{
}
///
/// Mapping column
///
/// Column formula, e.g. A, AB
/// Fallback value
public ColumnAttribute(string column, object @default) : this(Address.ParseColumn(column), @default)
{
}
}
}