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); } } }
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()); } }
private void Initialize() { m_RecipeTemplates = new RecipeTemplates(); m_BindingSource = new BindingSource(); m_BindingSource.DataSource = m_RecipeTemplates.TemplateList; this.dataGridView1.DataSource = m_BindingSource; this.dataGridView1.RowsAdded += new DataGridViewRowsAddedEventHandler(dataGridView1_RowsAdded); }
private void openTemplateToolStripMenuItem_Click(object sender, EventArgs e) { openFileDialog1.InitialDirectory = Directory.GetCurrentDirectory() + @"\Templates"; if (DialogResult.OK == openFileDialog1.ShowDialog()) { try { m_RecipeTemplates = new RecipeTemplates(); m_RecipeTemplates.Load(openFileDialog1.FileName); m_BindingSource = new BindingSource(); m_BindingSource.DataSource = m_RecipeTemplates.TemplateList; this.dataGridView1.DataSource = m_BindingSource; this.dataGridView1.RowsAdded += new DataGridViewRowsAddedEventHandler(dataGridView1_RowsAdded); } catch(Exception ex) { Console.WriteLine(ex.ToString()); } } }
public void OpenTemplate() { m_Templates = new RecipeTemplates(TemplatePath); }