Skip to content

Support ColumnIndex Attribute #142

Closed

Description

@shps951023

image

Activity

  1. changed the title [-]Support ColumnIndex/Name/Ignore Attribute[/-] [+]Support ColumnIndex Attribute[/+] on Apr 2, 2021
  2. added
    help wanted
    on Apr 2, 2021
  3. shps951023 commented on Apr 3, 2021

    @shps951023
    MemberAuthor

    https://github.com/shps951023/MiniExcel/pull/144

    目前遇到的困難在於 一些使用Index Attribue,一些不用情況
    像是

    public class Demo
    {
                public int MyProperty { get; set; }  //index = 1
    
                public int MyProperty2 { get; set; } //index = 3
                public int MyProperty3 { get; set; } //index = 4
                [ExcelColumnIndex("A")] // equal column index 0
                public int MyProperty4 { get; set; }
                [ExcelColumnIndex(2)]
                public int MyProperty5 { get; set; } //index = 2
                public int MyProperty6 { get; set; } //index = 5
    }

    但還在考慮這個功能實不實用,自己沒用過這功能,但其他框架有提供才列在Issue

  4. shps951023 commented on Apr 9, 2021

    @shps951023
    MemberAuthor
            public class Issue142VO
            {
                [ExcelColumnIndex("F")]
                public int MyProperty7 { get; set; } //index = null
            }

    image

  5. added 2 commits that reference this issue on Apr 9, 2021
  6. shps951023 commented on Apr 9, 2021

    @shps951023
    MemberAuthor

    0.11.1

    Excel Column Name/Index/Ignore Attribute

    e.g

    input excel :

    image

    public class ExcelAttributeDemo
    {
        [ExcelColumnName("Column1")]
        public string Test1 { get; set; }
        [ExcelColumnName("Column2")]
        public string Test2 { get; set; }
        [ExcelIgnore]
        public string Test3 { get; set; }
        [ExcelColumnIndex("I")] // system will convert "I" to 8 index
        public string Test4 { get; set; } 
        public string Test5 { get; } //wihout set will ignore
        public string Test6 { get; private set; } //un-public set will ignore
        [ExcelColumnIndex(3)] // start with 0
        public string Test7 { get; set; }
    }
    
    var rows = MiniExcel.Query<ExcelAttributeDemo>(path).ToList();
    Assert.Equal("Column1", rows[0].Test1);
    Assert.Equal("Column2", rows[0].Test2);
    Assert.Null(rows[0].Test3);
    Assert.Equal("Test7", rows[0].Test4);
    Assert.Null(rows[0].Test5);
    Assert.Null(rows[0].Test6);
    Assert.Equal("Test4", rows[0].Test7);
  7. added 2 commits that reference this issue on Aug 29, 2026
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

    help wantedtodo

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions