private void Set(string sheet, string cell, object value, ref CExcel exls) { if (!exls.SetCellValue(sheet, cell, value)) { throw new Exception(String.Format("Could not set cell {} to value {2} in sheet {3}", cell, value, sheet)); } }
bool SetInput(ModuleProcess process, Dictionary <string, object> dataAsIS, Dictionary <string, object> dataVariant, KeyValuePair <string, string> settingCellMapping, Dictionary <string, string> propertyCellMapping, CExcel exls, out bool Used) { //Used = true; //Set(sheetSettings, settingCellMapping.Value, "Y", ref exls); //if (!SetProperties(process, dataAsIS, exls, propertyCellMapping)) // return false; //return true; Used = false; if (dataVariant.ContainsKey(settingCellMapping.Key)) { if (dataVariant[settingCellMapping.Key] as string == null) { process.CalcMessage = "Module setting not properly set in database"; return(false); } if (dataVariant[settingCellMapping.Key] as string == "Yes") { Used = true; Set(sheetSettings, settingCellMapping.Value, "Y", ref exls); if (!SetProperties(process, dataAsIS, exls, propertyCellMapping)) { return(false); } } else { exls.SetCellValue(sheetSettings, settingCellMapping.Value, "N"); } } else { exls.SetCellValue(sheetSettings, settingCellMapping.Value, "N"); } return(true); }
private Ecodistrict.Messaging.Output.Outputs CalcCheesePriceKpi(Dictionary <string, Input> indata, CExcel exls) { Ecodistrict.Messaging.Output.Outputs outputs = new Ecodistrict.Messaging.Output.Outputs(); try { foreach (var input in indata) { //Set all input values switch (input.Key) { case "Cheddar_Price": //C3 cell exls.SetCellValue("Sheet1", "C3", input.Value); break; case "Gamle_Ole_Price": exls.SetCellValue("Sheet1", "C4", input.Value); break; case "Vasterbotten_Price": exls.SetCellValue("Sheet1", "C5", input.Value); break; case "Edamer_Price": exls.SetCellValue("Sheet1", "C6", input.Value); break; case "Maasdamer_Price": exls.SetCellValue("Sheet1", "C7", input.Value); break; case "Gouda_Price": exls.SetCellValue("Sheet1", "C8", input.Value); break; default: break; } } //Get the Kpi value var kpiValue = exls.GetCellValue("Sheet1", "C17"); //Put it in the calc result outputs.Add(new Ecodistrict.Messaging.Output.Kpi(kpiValue, "Min Cheese price Kpi", "SEK")); return(outputs); } catch (Exception ex) { throw new Exception(string.Format("Could not calculate the cheese price Kpi!\n{0}", ex)); } }