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

please help, cannot mapped group columns #248

Open
JL-Yondu opened this issue Mar 27, 2023 · 1 comment
Open

please help, cannot mapped group columns #248

JL-Yondu opened this issue Mar 27, 2023 · 1 comment

Comments

@JL-Yondu
Copy link

Hi can you help with these one? I cannot mapped the group header columns into my model property. Is there a way to mapped this one? How to get the child within these group/parent: "Insured", "Home Address", "Provincial Address" ?

Please see this screenshot for test data:
Screenshot 2023-03-27 214917

@mganss
Copy link
Owner

mganss commented Mar 28, 2023

Unfortunately, there is currently no support for multiple nested properties with the same type, e.g. properties HomeAddress and WorkAddress of type Address in the example above. Also, header columns that span multiple rows are unsupported.

The simplest possible workaround that comes to mind is to create an intermediate class that is used just for mapping from Excel, then map the resulting objects to your final desired class hierarchy. For example:

public class CustomerExcel
{
    [Column(Letter = "A")]
    public string PolicyNumber { get; set; }
    [Column(Letter = "B")]
    public DateTime IssueDate { get; set; }
    [Column(Letter = "C")]
    public DateTime EffectiveDate { get; set; }
    // ...
    [Column(Letter = "I")]
    public string HomeHouseNo { get; set; }
    // ...
    [Column(Letter = "M")]
    public string WorkHouseNo { get; set; }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants