public void WriteToExcel(ValuesDynamicDictionary cache, FileHeaderInfo fileHeader, List <Dictionary <string, Value> > formulas) { //1. Column headline Console.WriteLine(cache.Count()); string[] rowHeadline = new string[fileHeader.ColumnsUsed.Count + formulas[0].Keys.Count]; int maxLen = fileHeader.ColumnsUsed.Count + formulas[0].Keys.Count; int tabOneRowCounter = NumberOfRows(FirstTab); //1. a) merge the headline from raw cache and formulas cache into a single array int invariant = 0; while (invariant < maxLen) { for (int i = 0; i < fileHeader.ColumnsUsed.Count; i++) { rowHeadline[invariant] = EQRMSRawColumns.ProcessedColumnIntAsKey[fileHeader.ColumnsUsed[i]]; ++invariant; } for (int i = 0; i < formulas[0].Count; i++) { var lol = formulas.First().Keys; rowHeadline[invariant] = lol.ElementAt(i); ++invariant; } } //1. b) write the headline Excel.Range h1 = FirstTab.Cells[tabOneRowCounter, 1]; Excel.Range h2 = FirstTab.Cells[tabOneRowCounter, rowHeadline.Length]; Excel.Range headerRange = FirstTab.get_Range(h1, h2); headerRange.Value2 = rowHeadline; tabOneRowCounter++; //2. a) merge two caches row at a time int rowsIndex = 0; while (rowsIndex < cache.Count()) { int columnIndex = 0; string[] row = new string[cache.ValuesUnbound.Count + formulas[0].Count]; //Raw extracted data for (int i = 0; i < fileHeader.ColumnsUsed.Count; i++) { row[columnIndex] = cache.GetValue(fileHeader.ColumnsUsed[i], rowsIndex).ToString(); ++columnIndex; } //Our re-calculated formulas using Antlr for (int i = 0; i < formulas[rowsIndex].Count; i++) { row[columnIndex] = formulas[rowsIndex].Values.ElementAt(i).ToString(); ++columnIndex; } ++rowsIndex; //2b) Write the row Excel.Range c1 = FirstTab.Cells[tabOneRowCounter, 1]; Excel.Range c2 = FirstTab.Cells[tabOneRowCounter, row.Length]; Excel.Range firstTabRangeFormula = FirstTab.get_Range(c1, c2); firstTabRangeFormula.Value2 = row; ++tabOneRowCounter; } }
public void WriteFormulas() { Excel.Range rng = FirstTab.Cells[1, NumberOfColumns(FirstTab)]; Excel.Range searchRange = FirstTab.get_Range(rng); }