Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support ColumnIndex Attribute #142

Closed
shps951023 opened this issue Apr 2, 2021 · 3 comments
Closed

Support ColumnIndex Attribute #142

shps951023 opened this issue Apr 2, 2021 · 3 comments
Labels
help wanted Extra attention is needed todo

Comments

@shps951023
Copy link
Member

shps951023 commented Apr 2, 2021

image

@shps951023 shps951023 changed the title Support ColumnIndex/Name/Ignore Attribute Support ColumnIndex Attribute Apr 2, 2021
@shps951023 shps951023 added help wanted Extra attention is needed todo labels Apr 2, 2021
@shps951023
Copy link
Member Author

shps951023 commented Apr 3, 2021

#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

@shps951023
Copy link
Member Author

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

image

shps951023 added a commit that referenced this issue Apr 9, 2021
- [New] Support Support ColumnIndex Attribute [#142](#142) & [#I3I3EB](https://gitee.com/dotnetchina/MiniExcel/issues/I3I3EB)
- [Bug] Fix issue #157 : Special conditions will get the wrong worksheet name
- [Update] issue #150 : SaveAs input IEnuerable<valuetype> should throw clear msg exception
shps951023 added a commit that referenced this issue Apr 9, 2021
- [New] Support Support ColumnIndex Attribute [#142](#142) & [#I3I3EB](https://gitee.com/dotnetchina/MiniExcel/issues/I3I3EB)
- [Bug] Fix issue #157 : Special conditions will get the wrong worksheet name
- [Update] issue #150 : SaveAs input IEnuerable<valuetype> should throw clear msg exception
@shps951023
Copy link
Member Author

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);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed todo
Projects
Status: Done
Development

No branches or pull requests

1 participant