Nested object issue read from excel file
See original GitHub issueHi There, I’m having issue with nested class to read from excel file.
When i read the file, i’m getting parse error for the class PriceDetail as a list. What is the mistake am i doing? thanks for your help.
I have attached the sample excel file as well.
string excelfilepath = fileDialog.FileName;
var excel = new ExcelMapper(excelfilepath) { TrackObjects = true };
excel.AddMapping<Products>("Mainproduct", p => p.Mainproduct);
excel.AddMapping<Products>("Name", p => p.Name);
excel.AddMapping<Products>("Visible", p => p.Visible);
excel.AddMapping<Products>("NameIcon", p => p.NameIcon);
excel.AddMapping<Products>("SysId", p => p.SysId);
excel.AddMapping<PriceDetail>("ID", p => p.ID);
excel.AddMapping<PriceDetail>("FromQuantity", p => p.FromQuantity);
excel.AddMapping<PriceDetail>("Price", p => p.Price);
excel.AddMapping<PriceDetail>("ServiceFee", p => p.ServiceFee);
ProductPriceList = new ObservableCollection<Products>(excel.Fetch<Products>());
View = CollectionViewSource.GetDefaultView(ProductPriceList);
private ObservableCollection<Products> productpricelist;
public ObservableCollection<Products> ProductPriceList
{
get { return productpricelist; }
set
{
productpricelist = value;
OnPropertyChanged("ProductPriceList");
}
}
public class Products
{
public string SysId { get; set; }
public string Mainproduct { get; set; }
public string Name { get; set; }
public string Visible { get; set; }
public string From { get; set; }
public List<PriceDetail> Prices { get; set; } = new List<PriceDetail>();
public string NameIcon { get; set; }
}
public class PriceDetail
{
public string ID { get; set; }
public string FromQuantity { get; set; }
public string Price { get; set; }
public string ServiceFee { get; set; }
}
Issue Analytics
- State:
- Created 7 months ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
How can I access and process nested arrays on JSON to ...
So that i can run the code and my end and check the issue. ... a Json(with array and objects) and export the...
Read more >Read from Multiple Excel Tables to Nested JSON
The data I'm trying to come from is an Excel document with multiple ... I have no problem working with to populate the...
Read more >Excel to JSON: Multilayer nested arrays/objects
This JSON file will be created out of an Excel file. ... So I tried to repeat the first steps for the next...
Read more >Importing data from a nested JSON file to Excel
Solved: Hey guys, I am desperately trying to parse the data from a nested JSON file (that has many records and lists in...
Read more >xlsx to nested JSON · Issue #1591
Is it possible to read a xlsx file and convert it to a nested JSON? (i'm using node.js). For example, this table: Name...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
HI there, all good with small minor issue when i export the datagrid to excel just an empty col PriceDetail is created as its part of the class. I think i can delete this manually. Thanks so much for your help. Have a good day
Is there anything that does not work re import/export to/from Excel?