public static void MapDataFromExcel(string fileName, IEnumerable<RecipeVariable> itemList)
 {
     using (IExcelEngine excelEngine = new ExcelEngine(fileName))
     {
         foreach (RecipeVariable rv in itemList)
         {
             rv.Value = GetCell(rv.CellMap, excelEngine);
         }
     }
 }
        public static VariableCollections MapDataFromExcel(string fileName, IList<RecipeTemplateItem> items)
        {
            List<RecipeVariable> sendVariableList = new List<RecipeVariable>();
            List<RecipeVariable> receiveVariableList = new List<RecipeVariable>();
            Dictionary<string, object[]> rangeData = new Dictionary<string, object[]>();

            using (IExcelEngine excelEngine = new ExcelEngine(fileName))
            {
                foreach (RecipeTemplateItem item in items)
                {
                    if (item.ItemType == RecipeTemplateItemType.Cell)
                    {
                        object data = GetCell(item.CellStart, excelEngine);
                        sendVariableList.Add(new RecipeVariable(item.SendName, data));
                        receiveVariableList.Add(new RecipeVariable(item.ReceiveName));
                    }

                    if (item.ItemType == RecipeTemplateItemType.Range)
                    {
                        object[] dataRange = GetRange(item.CellStart, item.CellEnd, excelEngine);
                        rangeData.Add(item.SendName, dataRange);
                    }
                }

                foreach (KeyValuePair<string, object[]> kvp in rangeData)
                {
                    sendVariableList.AddRange(MapRangeData(kvp.Key, kvp.Value));
                }
            }

            return new VariableCollections(sendVariableList, receiveVariableList);
        }
 public static void WriteExcelData(string destinationFile, RecipeTemplates templates, IEnumerable<RecipeVariable> variableList)
 {
     try
     {
         using (IExcelEngine excelEngine = new ExcelEngine(destinationFile))
         {
             foreach (RecipeVariable rv in variableList)
             {
                 excelEngine.WriteCellValue(rv.CellMap, rv.Value);
             }
             excelEngine.Save(destinationFile);
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.ToString());
     }
 }
        public static void WriteExcelData(string tempFile, string destinationFile, RecipeTemplates templates, IEnumerable<RecipeVariable> variableList)
        {
            try
            {
                RecipeMasterServices.WriteNewProductionFile(tempFile);

                using (IExcelEngine excelEngine = new ExcelEngine(tempFile))
                {
                    foreach (RecipeVariable rv in variableList)
                    {
                        excelEngine.WriteCellValue(rv.CellMap, rv.Value);
                    }
                    RecipeMasterServices.RenameExistingFile(destinationFile, false);
                    excelEngine.Save(destinationFile);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
            finally
            {
                if (File.Exists(tempFile))
                {
                    File.Delete(tempFile);
                }
            }
        }
 private void btnViewExcel_Click(object sender, EventArgs e)
 {
     IExcelEngine excelEngine = new ExcelEngine(openFileDialog1.FileName);
     excelEngine.SetVisibleTo(true);
 }