private void GenerateNonQueryCommandsForDeleteGCELLMAGRP(string dbFile) { List <string> cols = new List <string>(); DataSet aSet = IOFileOperation.ReadExcelFile(dbFile, "GCELLMAGRP"); foreach (DataColumn dataColumn in aSet.Tables[0].Columns) { cols.Add(dataColumn.ColumnName); } string tempCommand = "set "; foreach (string col in cols) { tempCommand += col + "=' ', "; } tempCommand = tempCommand.Trim().Substring(0, tempCommand.Trim().LastIndexOf(',')); foreach (Dictionary <string, string> dictionary in DeleteGCELLMAGRP) { string command = "update [GCELLMAGRP$] " + tempCommand + " where BSCName='" + dictionary["BSCName"] + "' and CELLID='" + dictionary["CELLID"] + "' and HOPINDEX='" + dictionary["HOPINDEX"] + "';"; nonQueryCommands.Add(command); } }
private void LoadG2GNCell() { DataSet aSet = IOFileOperation.ReadExcelFile(dbFileNameNeighbor, "G2GNCELL"); List <string> cols = new List <string>(); foreach (DataColumn dataColumn in aSet.Tables[0].Columns) { cols.Add(dataColumn.ColumnName); } foreach (DataRow dataRow in aSet.Tables[0].Rows) { Dictionary <string, string> aDictionary = new Dictionary <string, string>(); foreach (string col in cols) { aDictionary.Add(col, dataRow[col].ToString()); } string index = "BSC-" + dataRow["BSCName"].ToString() + "_CELLNAME-" + dataRow["SRCCELLNAME"].ToString(); if (g2GnCell.ContainsKey(index)) { g2GnCell[index].Add(aDictionary); } else { List <Dictionary <string, string> > aList = new List <Dictionary <string, string> >(); aList.Add(aDictionary); g2GnCell.Add(index, aList); } } }
public void ReadInputDataFiles() { ReadInputFiles(); List <Dictionary <string, string> > sortedData = SortInputDataIntoDictionary(); SetTrunkWiseData(sortedData); GenerateOutputReportData(); IOFileOperation.CreateExelFile(outputReportData, Directory.GetCurrentDirectory(), "Report"); }
private void ReadInputFile() { DataSet aSet = IOFileOperation.ReadExcelFile(inputFile, "PSCInfo"); foreach (DataRow dataRow in aSet.Tables[0].Rows) { PSCInfo aPscInfo = new PSCInfo(); aPscInfo.RNCName = dataRow["RNCName"].ToString().Trim(); aPscInfo.CELLID = dataRow["CELLID"].ToString().Trim(); aPscInfo.CELLNAME = dataRow["CELLNAME"].ToString().Trim(); aPscInfo.NEWPSC = dataRow["NEW PSC"].ToString().Trim(); if (aPscInfo.RNCName.Trim().Length != 0) { pscInfo.Add(aPscInfo); } } aSet = IOFileOperation.ReadExcelFile(inputFile, "Neighbor_Delete(3G-3G)"); foreach (DataRow dataRow in aSet.Tables[0].Rows) { Neighbor_Delete aNeighborDelete = new Neighbor_Delete(); aNeighborDelete.RNCName = dataRow["RNCName"].ToString().Trim(); aNeighborDelete.RNCID = dataRow["RNC ID"].ToString().Trim(); aNeighborDelete.CellID = dataRow["Cell ID"].ToString().Trim(); aNeighborDelete.RNCIDofNeighboringCell = dataRow["RNC ID of a neighboring cell"].ToString().Trim(); aNeighborDelete.NeighboringCellID = dataRow["Neighboring Cell ID"].ToString().Trim(); if (aNeighborDelete.RNCName.Trim().Length != 0) { neighborDelete.Add(aNeighborDelete); } } aSet = IOFileOperation.ReadExcelFile(inputFile, "External3G_Update"); foreach (DataRow dataRow in aSet.Tables[0].Rows) { External3G_Update aExternal3GUpdate = new External3G_Update(); aExternal3GUpdate.RNCName = dataRow["RNCName"].ToString().Trim(); aExternal3GUpdate.NeighboringRNCID = dataRow["Neighboring RNC ID"].ToString().Trim(); aExternal3GUpdate.CellIDofNeighboringRNC = dataRow["Cell ID of Neighboring RNC"].ToString().Trim(); aExternal3GUpdate.PSCRAMBCODE = dataRow["PSCRAMBCODE"].ToString().Trim(); if (aExternal3GUpdate.RNCName.Trim().Length != 0) { external3GUpdate.Add(aExternal3GUpdate); } } }
public string ProcessTemplate(string inputFile, string templateFile) { this.inputFile = inputFile; this.templateFile = templateFile; ReadInputFile(); ReadTemplateFile(); UpdateTemplateData(); string curr = Directory.GetCurrentDirectory(); IOFileOperation.CreateExelFile(templateData, curr); if (File.Exists(curr + @"\DataNotFound.xlsx")) { File.Delete(curr + @"\DataNotFound.xlsx"); } if (notFound.Count != 0) { IOFileOperation.CreateExelFile(notFound, curr, "DataNotFound.xlsx"); } return("Finished"); }
private void ReadWOInput(string inputFile) { DataSet aSet = IOFileOperation.ReadExcelFile(inputFile, "Input"); int count = aSet.Tables[0].Rows.Count; foreach (DataRow dataRow in aSet.Tables[0].Rows) { if (dataRow["NEW BCCH"].ToString().Trim().Length != 0) { FrequencyChangeData aData = new FrequencyChangeData(); aData.LAC = dataRow["LAC"].ToString().Trim(); aData.CI = dataRow["CI"].ToString().Trim(); aData.OldFrequency = dataRow["BCCH"].ToString().Trim(); aData.NewFrequency = dataRow["NEW BCCH"].ToString().Trim(); woInputFrequency.Add(aData); } if (dataRow["NEW TCH1"].ToString().Trim().Length != 0) { FrequencyChangeData aData1 = new FrequencyChangeData(); aData1.LAC = dataRow["LAC"].ToString().Trim(); aData1.CI = dataRow["CI"].ToString().Trim(); aData1.OldFrequency = dataRow["TCH1"].ToString().Trim(); aData1.NewFrequency = dataRow["NEW TCH1"].ToString().Trim(); woInputFrequency.Add(aData1); } if (dataRow["NEW TCH2"].ToString().Trim().Length != 0) { FrequencyChangeData aData2 = new FrequencyChangeData(); aData2.LAC = dataRow["LAC"].ToString().Trim(); aData2.CI = dataRow["CI"].ToString().Trim(); aData2.OldFrequency = dataRow["TCH2"].ToString().Trim(); aData2.NewFrequency = dataRow["NEW TCH2"].ToString().Trim(); woInputFrequency.Add(aData2); } if (dataRow["NEW TCH3"].ToString().Trim().Length != 0) { FrequencyChangeData aData3 = new FrequencyChangeData(); aData3.LAC = dataRow["LAC"].ToString().Trim(); aData3.CI = dataRow["CI"].ToString().Trim(); aData3.OldFrequency = dataRow["TCH3"].ToString().Trim(); aData3.NewFrequency = dataRow["NEW TCH3"].ToString().Trim(); woInputFrequency.Add(aData3); } if (dataRow["NEW TCH4"].ToString().Trim().Length != 0) { FrequencyChangeData aData4 = new FrequencyChangeData(); aData4.LAC = dataRow["LAC"].ToString().Trim(); aData4.CI = dataRow["CI"].ToString().Trim(); aData4.OldFrequency = dataRow["TCH4"].ToString().Trim(); aData4.NewFrequency = dataRow["NEW TCH4"].ToString().Trim(); woInputFrequency.Add(aData4); } if (dataRow["NEW TCH5"].ToString().Length != 0) { FrequencyChangeData aData5 = new FrequencyChangeData(); aData5.LAC = dataRow["LAC"].ToString().Trim(); aData5.CI = dataRow["CI"].ToString().Trim(); aData5.OldFrequency = dataRow["TCH5"].ToString().Trim(); aData5.NewFrequency = dataRow["NEW TCH5"].ToString().Trim(); woInputFrequency.Add(aData5); } if (dataRow["NEW TCH6"].ToString().Length != 0) { FrequencyChangeData aData6 = new FrequencyChangeData(); aData6.LAC = dataRow["LAC"].ToString().Trim(); aData6.CI = dataRow["CI"].ToString().Trim(); aData6.OldFrequency = dataRow["TCH6"].ToString().Trim(); aData6.NewFrequency = dataRow["NEW TCH6"].ToString().Trim(); woInputFrequency.Add(aData6); } if (dataRow["NEW TCH7"].ToString().Length != 0) { FrequencyChangeData aData7 = new FrequencyChangeData(); aData7.LAC = dataRow["LAC"].ToString().Trim(); aData7.CI = dataRow["CI"].ToString().Trim(); aData7.OldFrequency = dataRow["TCH7"].ToString().Trim(); aData7.NewFrequency = dataRow["NEW TCH7"].ToString().Trim(); woInputFrequency.Add(aData7); } if (dataRow["NEW TCH8"].ToString().Trim().Length != 0) { FrequencyChangeData aData8 = new FrequencyChangeData(); aData8.LAC = dataRow["LAC"].ToString().Trim(); aData8.CI = dataRow["CI"].ToString(); aData8.OldFrequency = dataRow["TCH8"].ToString().Trim(); aData8.NewFrequency = dataRow["NEW TCH8"].ToString().Trim(); woInputFrequency.Add(aData8); } if (dataRow["NEW TCH9"].ToString().Length != 0) { FrequencyChangeData aData9 = new FrequencyChangeData(); aData9.LAC = dataRow["LAC"].ToString().Trim(); aData9.CI = dataRow["CI"].ToString().Trim(); aData9.OldFrequency = dataRow["TCH9"].ToString().Trim(); aData9.NewFrequency = dataRow["NEW TCH9"].ToString().Trim(); woInputFrequency.Add(aData9); } if (dataRow["NEW TCH10"].ToString().Length != 0) { FrequencyChangeData aData10 = new FrequencyChangeData(); aData10.LAC = dataRow["LAC"].ToString().Trim(); aData10.CI = dataRow["CI"].ToString().Trim(); aData10.OldFrequency = dataRow["TCH10"].ToString().Trim(); aData10.NewFrequency = dataRow["NEW TCH10"].ToString().Trim(); woInputFrequency.Add(aData10); } if (dataRow["NEW TCH11"].ToString().Length != 0) { FrequencyChangeData aData11 = new FrequencyChangeData(); aData11.LAC = dataRow["LAC"].ToString().Trim(); aData11.CI = dataRow["CI"].ToString().Trim(); aData11.OldFrequency = dataRow["TCH11"].ToString().Trim(); aData11.NewFrequency = dataRow["NEW TCH11"].ToString().Trim(); woInputFrequency.Add(aData11); } string bsic = dataRow["NEW BSIC"].ToString().Trim(); if (dataRow["NEW BSIC"].ToString().Trim().Length != 0) { BSICChangeData aData12 = new BSICChangeData(); aData12.LAC = dataRow["LAC"].ToString().Trim(); aData12.CI = dataRow["CI"].ToString().Trim(); aData12.OldBSIC = dataRow["BSIC"].ToString().Trim(); aData12.NewBSIC = dataRow["NEW BSIC"].ToString().Trim(); woInputBSIC.Add(aData12); } } }
private void LoadTemplateData(string dbFileName) { DataSet aSet = IOFileOperation.ReadExcelFile(dbFileName, "GCELL"); List <string> cols = new List <string>(); foreach (DataColumn dataColumn in aSet.Tables[0].Columns) { cols.Add(dataColumn.ColumnName); } foreach (DataRow dataRow in aSet.Tables[0].Rows) { Dictionary <string, string> aDictionary = new Dictionary <string, string>(); foreach (string col in cols) { aDictionary.Add(col, dataRow[col].ToString()); } GCELL.Add(aDictionary); } cols = new List <string>(); aSet = IOFileOperation.ReadExcelFile(dbFileName, "GCELLFREQ_FREQ"); foreach (DataColumn dataColumn in aSet.Tables[0].Columns) { cols.Add(dataColumn.ColumnName); } foreach (DataRow dataRow in aSet.Tables[0].Rows) { Dictionary <string, string> aDictionary = new Dictionary <string, string>(); foreach (string col in cols) { aDictionary.Add(col, dataRow[col].ToString()); } GCELLFREQ.Add(aDictionary); } cols = new List <string>(); aSet = IOFileOperation.ReadExcelFile(dbFileName, "GTRX"); foreach (DataColumn dataColumn in aSet.Tables[0].Columns) { cols.Add(dataColumn.ColumnName); } foreach (DataRow dataRow in aSet.Tables[0].Rows) { Dictionary <string, string> aDictionary = new Dictionary <string, string>(); foreach (string col in cols) { aDictionary.Add(col, dataRow[col].ToString()); } GTRX.Add(aDictionary); } cols = new List <string>(); aSet = IOFileOperation.ReadExcelFile(dbFileName, "GCELLMAGRP"); foreach (DataColumn dataColumn in aSet.Tables[0].Columns) { cols.Add(dataColumn.ColumnName); } foreach (DataRow dataRow in aSet.Tables[0].Rows) { Dictionary <string, string> aDictionary = new Dictionary <string, string>(); foreach (string col in cols) { aDictionary.Add(col, dataRow[col].ToString()); } GCELLMAGRP.Add(aDictionary); } cols = new List <string>(); aSet = IOFileOperation.ReadExcelFile(dbFileName, "GTRXCHANHOP"); foreach (DataColumn dataColumn in aSet.Tables[0].Columns) { cols.Add(dataColumn.ColumnName); } foreach (DataRow dataRow in aSet.Tables[0].Rows) { Dictionary <string, string> aDictionary = new Dictionary <string, string>(); foreach (string col in cols) { aDictionary.Add(col, dataRow[col].ToString()); } GTRXCHANHOP.Add(aDictionary); } }
private void LoadInputFile(string inputFile) { int index = 0; DataSet aSet = IOFileOperation.ReadExcelFile(inputFile, "Delete GCELLMAGRP"); List <string> cols = new List <string>(); foreach (DataColumn dataColumn in aSet.Tables[0].Columns) { cols.Add(dataColumn.ColumnName); } foreach (DataRow dataRow in aSet.Tables[0].Rows) { if (index != 0) { Dictionary <string, string> aDictionary = new Dictionary <string, string>(); foreach (string col in cols) { aDictionary.Add(col, dataRow[col].ToString()); } DeleteGCELLMAGRP.Add(aDictionary); } index++; } index = 0; aSet = IOFileOperation.ReadExcelFile(inputFile, "Create GCELLMAGRP"); cols = new List <string>(); foreach (DataColumn dataColumn in aSet.Tables[0].Columns) { cols.Add(dataColumn.ColumnName); } foreach (DataRow dataRow in aSet.Tables[0].Rows) { if (index != 0) { Dictionary <string, string> aDictionary = new Dictionary <string, string>(); foreach (string col in cols) { aDictionary.Add(col, dataRow[col].ToString()); } CreateGCELLMAGRP.Add(aDictionary); } index++; } index = 0; aSet = IOFileOperation.ReadExcelFile(inputFile, "GTRXHOP"); cols = new List <string>(); foreach (DataColumn dataColumn in aSet.Tables[0].Columns) { cols.Add(dataColumn.ColumnName); } foreach (DataRow dataRow in aSet.Tables[0].Rows) { if (index != 0) { Dictionary <string, string> aDictionary = new Dictionary <string, string>(); foreach (string col in cols) { aDictionary.Add(col, dataRow[col].ToString()); } GTRXHOP.Add(aDictionary); } index++; } index = 0; aSet = IOFileOperation.ReadExcelFile(inputFile, "GTRXCHANHOP"); cols = new List <string>(); foreach (DataColumn dataColumn in aSet.Tables[0].Columns) { cols.Add(dataColumn.ColumnName); } foreach (DataRow dataRow in aSet.Tables[0].Rows) { if (index != 0) { Dictionary <string, string> aDictionary = new Dictionary <string, string>(); foreach (string col in cols) { aDictionary.Add(col, dataRow[col].ToString()); } GTRXCHANHOP.Add(aDictionary); } index++; } }
private void GenerateNonQueryCommandsForCreateGCELLMAGRP(string dbFile) { List <string> cols = new List <string>(); DataSet aSet = IOFileOperation.ReadExcelFile(dbFile, "GCELLMAGRP"); foreach (DataColumn dataColumn in aSet.Tables[0].Columns) { cols.Add(dataColumn.ColumnName); } Dictionary <string, Dictionary <string, string> > gcellMaGrpDataExistData = new Dictionary <string, Dictionary <string, string> >(); foreach (DataRow dataRow in aSet.Tables[0].Rows) { if (dataRow["BSCName"].ToString().Trim().Length > 0) { if (dataRow["BSCName"].ToString() != "BSC Name" && dataRow["BSCName"].ToString().Trim().Length > 0) { string index = "BSC-" + dataRow["BSCName"].ToString() + "_CELLID-" + dataRow["CELLID"].ToString() + "_HOPINDEX-" + dataRow["HOPINDEX"].ToString(); Dictionary <string, string> aDictionary = new Dictionary <string, string>(); foreach (string col in cols) { aDictionary.Add(col, dataRow[col].ToString()); } gcellMaGrpDataExistData.Add(index, aDictionary); } } } string command = string.Empty; foreach (Dictionary <string, string> dictionary in CreateGCELLMAGRP) { string index = "BSC-" + dictionary["BSCName"] + "_CELLID-" + dictionary["CELLID"] + "_HOPINDEX-" + dictionary["HOPINDEX"]; //if (gcellMaGrpDataExistData.ContainsKey(index)) //{ // string tempCommand = "set "; // foreach (KeyValuePair<string, string> keyValuePair in dictionary) // { // tempCommand += keyValuePair.Key + "='" + keyValuePair.Value + "', "; // } // tempCommand = tempCommand.Trim().Substring(0, tempCommand.Trim().LastIndexOf(',')); // command = "update [GCELLMAGRP$] " + tempCommand + " where BSCName='" + gcellMaGrpDataExistData[index]["BSCName"] // + "' and CELLID='" + gcellMaGrpDataExistData[index]["CELLID"] + "' and HOPINDEX='" + gcellMaGrpDataExistData[index]["HOPINDEX"] + "';"; // nonQueryCommands.Add(command); //} command = "insert into [GCELLMAGRP$] ( "; foreach (KeyValuePair <string, string> keyValuePair in dictionary) { command += keyValuePair.Key + ", "; } command = command.Trim().Substring(0, command.LastIndexOf(',')) + ") values ("; foreach (KeyValuePair <string, string> keyValuePair in dictionary) { command += "'" + keyValuePair.Value + "', "; } command = command.Trim().Substring(0, command.LastIndexOf(',')) + ");"; nonQueryCommands.Add(command); } }
private void ReadWOInput(string inputFile) { DataSet aSet = IOFileOperation.ReadExcelFile(inputFile, "Input"); foreach (DataRow dataRow in aSet.Tables[0].Rows) { if (dataRow["NEW BCCH"].ToString().Trim().Length != 0) { FrequencyChangeData aData = new FrequencyChangeData(); aData.LAC = dataRow["LAC"].ToString().Trim(); aData.CI = dataRow["CI"].ToString().Trim(); aData.OldFrequency = dataRow["BCCH"].ToString().Trim(); aData.NewFrequency = dataRow["NEW BCCH"].ToString().Trim(); string index = "LAC-" + aData.LAC + "_CI-" + aData.CI; if (gcellByLacCi.ContainsKey(index)) { aData.BSCName = gcellByLacCi[index]["BSCName"]; aData.CELLNAME = gcellByLacCi[index]["CELLNAME"]; aData.CELLID = gcellByLacCi[index]["CELLID"]; } woInputFrequency.Add(aData); } string bsic = dataRow["NEW BSIC"].ToString().Trim(); if (dataRow["NEW BSIC"].ToString().Trim().Length != 0) { BSICChangeData aData = new BSICChangeData(); aData.LAC = dataRow["LAC"].ToString().Trim(); aData.CI = dataRow["CI"].ToString().Trim(); aData.OldBSIC = dataRow["BSIC"].ToString().Trim(); aData.NewBSIC = dataRow["NEW BSIC"].ToString().Trim(); string index = "LAC-" + aData.LAC + "_CI-" + aData.CI; if (gcellByLacCi.ContainsKey(index)) { aData.BSCName = gcellByLacCi[index]["BSCName"]; aData.CELLNAME = gcellByLacCi[index]["CELLNAME"]; aData.CELLID = gcellByLacCi[index]["CELLID"]; } woInputBSIC.Add(aData); } } aSet = IOFileOperation.ReadExcelFile(inputFile, "NeighborDelete"); foreach (DataRow dataRow in aSet.Tables[0].Rows) { if (dataRow["Cell ID"].ToString().Trim().Length != 0) { Dictionary <string, string> aDictionary = new Dictionary <string, string>(); aDictionary.Add("SourceCell", dataRow["Cell ID"].ToString().Trim()); aDictionary.Add("LAC", dataRow["Cell ID"].ToString().Trim()); aDictionary.Add("CI", dataRow["Cell ID"].ToString().Trim()); aDictionary.Add("NeighborCell", dataRow["Neighbour Cell ID"].ToString().Trim()); aDictionary.Add("NeighborLAC", dataRow["NLAC"].ToString().Trim()); aDictionary.Add("NeigborCI", dataRow["NCI"].ToString().Trim()); woInputNeighborDelete.Add(aDictionary); } } }
private void LoadGcellData() { DataSet aSet = IOFileOperation.ReadExcelFile(dbFileNameGCELL, "GCELL"); List <string> cols = new List <string>(); foreach (DataColumn dataColumn in aSet.Tables[0].Columns) { cols.Add(dataColumn.ColumnName); } foreach (DataRow dataRow in aSet.Tables[0].Rows) { string index = "LAC-" + dataRow["LAC"].ToString() + "_CI-" + dataRow["CI"].ToString(); Dictionary <string, string> aDictionary = new Dictionary <string, string>(); foreach (string col in cols) { aDictionary.Add(col, dataRow[col].ToString()); } if (!gcellByLacCi.ContainsKey(index)) { gcellByLacCi.Add(index, aDictionary); } index = "CellName-" + dataRow["CELLNAME"].ToString(); if (!gcellByCellName.ContainsKey(index)) { gcellByCellName.Add(index, aDictionary); } } Dictionary <string, Dictionary <string, string> > gtrx = new Dictionary <string, Dictionary <string, string> >(); aSet = IOFileOperation.ReadExcelFile(dbFileNameGCELL, "GTRX"); cols = new List <string>(); foreach (DataColumn dataColumn in aSet.Tables[0].Columns) { cols.Add(dataColumn.ColumnName); } foreach (DataRow dataRow in aSet.Tables[0].Rows) { string index = "BSC-" + dataRow["BSCName"].ToString() + "_CELLID-" + dataRow["CELLID"].ToString(); if (dataRow["ISMAINBCCH"].ToString() == "YES") { Dictionary <string, string> aDictionary = new Dictionary <string, string>(); foreach (string col in cols) { aDictionary.Add(col, dataRow[col].ToString()); } if (!gtrx.ContainsKey(index)) { gtrx.Add(index, aDictionary); } } } foreach (KeyValuePair <string, Dictionary <string, string> > keyValuePair in gcellByLacCi) { Dictionary <string, string> aDictionary = (Dictionary <string, string>)keyValuePair.Value; string gtrxIndex = "BSC-" + aDictionary["BSCName"].ToString() + "_CELLID-" + aDictionary["CELLID"].ToString(); if (gtrx.ContainsKey(gtrxIndex)) { aDictionary.Add("BCCH", gtrx[gtrxIndex]["FREQ"]); } else { aDictionary.Add("BCCH", ""); } } }
private void ReadTemplateFile() { List <Dictionary <string, string> > CELL = new List <Dictionary <string, string> >(); DataSet aSet = IOFileOperation.ReadExcelMacroFile(templateFile, "CELL"); List <string> cols = new List <string>(); foreach (DataColumn dataColumn in aSet.Tables[0].Columns) { cols.Add(dataColumn.ColumnName); } foreach (DataRow dataRow in aSet.Tables[0].Rows) { Dictionary <string, string> aDictionary = new Dictionary <string, string>(); foreach (string col in cols) { aDictionary.Add(col, dataRow[col].ToString()); } CELL.Add(aDictionary); } templateData.Add("CELL", CELL); List <Dictionary <string, string> > NRNCCELL = new List <Dictionary <string, string> >(); aSet = IOFileOperation.ReadExcelMacroFile(templateFile, "NRNCCELL"); cols = new List <string>(); foreach (DataColumn dataColumn in aSet.Tables[0].Columns) { cols.Add(dataColumn.ColumnName); } foreach (DataRow dataRow in aSet.Tables[0].Rows) { Dictionary <string, string> aDictionary = new Dictionary <string, string>(); foreach (string col in cols) { aDictionary.Add(col, dataRow[col].ToString()); } NRNCCELL.Add(aDictionary); } templateData.Add("NRNCCELL", NRNCCELL); List <Dictionary <string, string> > INTRAFREQNCELL = new List <Dictionary <string, string> >(); aSet = IOFileOperation.ReadExcelMacroFile(templateFile, "INTRAFREQNCELL"); cols = new List <string>(); foreach (DataColumn dataColumn in aSet.Tables[0].Columns) { cols.Add(dataColumn.ColumnName); } foreach (DataRow dataRow in aSet.Tables[0].Rows) { Dictionary <string, string> aDictionary = new Dictionary <string, string>(); foreach (string col in cols) { aDictionary.Add(col, dataRow[col].ToString()); } INTRAFREQNCELL.Add(aDictionary); } templateData.Add("INTRAFREQNCELL", INTRAFREQNCELL); }