Narasiman nar

Narasiman nar

  • NA
  • 64
  • 22.2k

Display answers based on id each question id

May 21 2018 12:40 PM
Display answers based on id each questionItried it isnotworking
in excel i have following data as follows
 
ID Name Suggestions
1 OLAMDEV "Produto preferido":"Algodao", "Plantou algodaono":"Sim"
2 OLAMDEV1 "Produto preferido":"Feij Buer","Plantou algodaono":"Sim"
 
From above i want output in excel
 
id name Produto preferido Plantou algodaono
1 OLAMDEV Algodao Sim
2 OLAMDEV1 Feji Buer Nao
 
Code as follows
 
int columnindex = 43;
List lst = new List();
foreach (DataRow row in dtFarmerFarmReports.Rows)
{
var dict = JsonConvert.DeserializeObject>(row["farm_detailsdata"].ToString());
string str = string.Empty;
lst.AddRange(dict.Keys);
}
var distinctList = lst.Distinct().ToList();
foreach (var data in distinctList)
{
columnindex++;
worksheet.Cells[2, columnindex].Value = data;
}
int col = 43;
List lsts = new List();
foreach (DataRow rowss in dtFarmerFarmReports.Rows)
{
var dicts = JsonConvert.DeserializeObject>(rows["farm_detailsdata"].ToString());
string str = string.Empty;
lst.AddRange(dicts.Values);
}
var distinct = lst.Distinct().ToList();
foreach (var datas in distinct)
{
col++;
worksheet.Cells[2, col].Value = datas;
}
 
When i run the above code i get output as follows
 
id name Produto preferido Plantou algodaono
1 OLAMDEV Algodao Sim Feji Buer Sim
2 OLAMDEV1
 
i want ouput as follows
 
id name Produto preferido Plantou algodaono
 
1 OLAMDEV Algodao Sim
2 OLAMDEV1 Feji Buer Sim
 
from the above what changes i have to made to display the answers based on each id.
Please help me.
what changes i have to made in my above code to display answers based on each id.

Answers (1)