void FillProfit(Excel.Worksheet ProfitSheet, int Row, string ticker, ProfitTicker item, Excel.Worksheet HistorySheet) { if ((ProfitSheet != null) && (Row > 1) && (ticker != null) && (ticker != "")) { if ((item == null) || (item.Count == 0)) //-V3024 { // позиции из "доходности" нет в портфелях или кол-во равно 0 - обнуляем (распродал) ProfitSheet.Cells[Row, 5] = ""; ProfitSheet.Cells[Row, 9] = ""; ProfitSheet.Cells[Row, 14] = ""; } else { ProfitSheet.Cells[Row, 1] = ticker; ProfitSheet.Cells[Row, 2] = item.name; ProfitSheet.Cells[Row, 4] = item.InstrumentTypeName; if (item.Count > 0) { if (item.IsCurrency) { ProfitSheet.Cells[Row, 9] = item.Count; } else { ProfitSheet.Cells[Row, 5] = item.Count; } } if (item.Nominal > 0) { ProfitSheet.Cells[Row, 6] = item.Nominal; } ProfitSheet.Cells[Row, 7] = item.currency; if ((item.Summa > 0) && (!item.IsCurrency)) { ProfitSheet.Cells[Row, 9] = item.Summa; } if (item.MarketSumma > 0) { ProfitSheet.Cells[Row, 14] = item.MarketSumma; } if (Row > 10) { // копируем формулы из предыдущей строки ProfitSheet.Cells[Row, 8].FormulaR1C1 = ProfitSheet.Cells[Row - 1, 8].FormulaR1C1; ProfitSheet.Cells[Row, 10].FormulaR1C1 = ProfitSheet.Cells[Row - 1, 10].FormulaR1C1; ProfitSheet.Cells[Row, 11].FormulaR1C1 = ProfitSheet.Cells[Row - 1, 11].FormulaR1C1; ProfitSheet.Cells[Row, 12].FormulaR1C1 = ProfitSheet.Cells[Row - 1, 12].FormulaR1C1; ProfitSheet.Cells[Row, 13].FormulaR1C1 = ProfitSheet.Cells[Row - 1, 13].FormulaR1C1; ProfitSheet.Cells[Row, 15].FormulaR1C1 = ProfitSheet.Cells[Row - 1, 15].FormulaR1C1; ProfitSheet.Cells[Row, 16].FormulaR1C1 = ProfitSheet.Cells[Row - 1, 16].FormulaR1C1; ProfitSheet.Cells[Row, 17].FormulaR1C1 = ProfitSheet.Cells[Row - 1, 17].FormulaR1C1; ProfitSheet.Cells[Row, 18].FormulaR1C1 = ProfitSheet.Cells[Row - 1, 18].FormulaR1C1; ProfitSheet.Cells[Row, 19].FormulaR1C1 = ProfitSheet.Cells[Row - 1, 19].FormulaR1C1; ProfitSheet.Cells[Row, 20].FormulaR1C1 = ProfitSheet.Cells[Row - 1, 20].FormulaR1C1; ProfitSheet.Cells[Row, 21].FormulaR1C1 = ProfitSheet.Cells[Row - 1, 21].FormulaR1C1; } // дополняем историю if (HistorySheet != null) { int max_rows_history = HistorySheet.UsedRange.Rows.Count; DateTime date = DateTime.Today; int _count = 0; for (int j = 2; j <= max_rows_history; j++) { if (ticker == MSExcel.GetRangeValue <string>(HistorySheet.Cells[j, 1])) { if (date == MSExcel.GetRangeValue <DateTime>(HistorySheet.Cells[j, 2])) { _count = j; break; } } } if (_count == 0) { _count = max_rows_history + 1; } if (_count > 1) { HistorySheet.Cells[_count, 1] = ticker; HistorySheet.Cells[_count, 2] = date; if (item.IsCurrency) { HistorySheet.Cells[_count, 3] = 1; } else { HistorySheet.Cells[_count, 3] = 0; } HistorySheet.Cells[_count, 4] = ProfitSheet.Cells[Row, 5]; HistorySheet.Cells[_count, 5] = ProfitSheet.Cells[Row, 7]; HistorySheet.Cells[_count, 6] = ProfitSheet.Cells[Row, 8]; HistorySheet.Cells[_count, 7] = ProfitSheet.Cells[Row, 9]; HistorySheet.Cells[_count, 8] = ProfitSheet.Cells[Row, 10]; HistorySheet.Cells[_count, 9] = ProfitSheet.Cells[Row, 12]; HistorySheet.Cells[_count, 10] = ProfitSheet.Cells[Row, 14]; HistorySheet.Cells[_count, 11] = ProfitSheet.Cells[Row, 15]; } } } } }