Skip to content

[BUG] - Column names past IV resolve to column A #1065

Closed

Description

@vtxe02023274

Description

CellReferenceConverter.GetNumericalIndex only looks the name up in the cached map, which is preloaded up to column IV (index 255). Any name past that returns 0 unless something earlier in the process happened to request that column, so [MiniExcelColumnIndex("IW")] and [MiniExcelColumn(IndexName = "IW")] resolve to column A.

public class Row
{
    [MiniExcelColumnIndex("A")] public string? First { get; set; }
    [MiniExcelColumnIndex("IW")] public string? Wide { get; set; }
}

MiniExcelV2.Exporters.GetOpenXmlExporter().Export(path, new[] { new Row { First = "a", Wide = "iw" } });

Expected Behavior

Wide is written to column IW. GetNumericalIndex("IW") returns 256, "XFD" returns 16383.

Actual Behavior

In a fresh process the export throws InvalidMappingException: Duplicate column index in type Row: 0. Without the A property it is written to column A. GetNumericalIndex("IW"), "AAA" and "XFD" all return 0.

Querying a sheet usually hides it, because reading a wide row fills the cache before the attributes are resolved. The same lookup is used for template ranges and ColumnMappingsProvider.

Workarounds

Use the numeric constructor, [MiniExcelColumnIndex(256)].

Environment

  • MiniExcel Version: master (2.0.0-preview.5)
  • .NET Version: net8.0, net10.0, net11.0
  • OS: Windows
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions