Narasiman nar

Narasiman nar

  • NA
  • 64
  • 22.2k

Display answers based on id each questionItried it isnotwork

May 20 2018 1:55 AM
  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":"Nao"

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<string> lst = new List<string>();
foreach (DataRow row in dtFarmerFarmReports.Rows)
{
var dict = JsonConvert.DeserializeObject<Dictionary<string, string>>(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<string> lsts = new List<string>();

foreach (DataRow rows in dtFarmerFarmReports.Rows)
{
foreach (DataRow rowss in dtFarmerFarmReports.Rows)
{
var dicts = JsonConvert.DeserializeObject<Dictionary<string, string>>(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 Algodao Sim Feji Buer Nao
1      OLAMDEV
2     OLAMDEV1  
 
from the above code answers are displaying after the questions.
 
i want to display answers in the next line
 
i want ouput as follows
 
id      name             Produto preferido            Plantou algodaono
1  OLAMDEV                Algodao                                  Sim
2  OLAMDEV1              Feji Buer                                   Nao
 
 from the above what changes i have to made to display the answers in the next line base on each id.
 
 
Please help me.