/// <summary> /// Создает общий шаблон для таблицы /// </summary> /// <param name="Parent">Родительская форма</param> /// <param name="Table">Исходная таблица</param> public static void CreateTemplate(BankLab Parent, DataGridView Table) { Excel.Application ExcelApp; ExcelApp = new Excel.Application(); ResFile Maket = new ResFile(bl_res_doc.Resource1.Maket, AppDomain.CurrentDomain.BaseDirectory + "~tmp.xlsx"); Maket.CreateFile(); Parent.CurrentProgressBar.SetProgressBarValue(35); ExcelApp.Workbooks.Open(Maket.FileName); Parent.CurrentProgressBar.SetProgressBarValue(50); Table.Columns.Add("Year", ExcelApp.Cells[1, 1].Value); Table.ColumnCount = 19; Parent.CurrentProgressBar.SetProgressBarValue(60); for (int i = 1; i <= 18; i++) { Table.Columns[i].Name = "X" + i.ToString(); Table.Columns[i].HeaderText = ExcelApp.Cells[1, i + 1].Value; Table.Columns[i].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft; } Parent.CurrentProgressBar.SetProgressBarValue(90); SetTablePropertyToCreateTamplate(Table); Parent.CurrentSideBar.AddTables(); ExcelApp.Workbooks.Close(); ExcelApp.Quit(); Maket.FreeFile(); Parent.CurrentMenu.ChangeMenuItemsEnable(true); }
public ParamForm(BankLab parent, DataGridView dataTable) { InitializeComponent(); Parent = parent; CurrentDataTable = dataTable; ShowParametrForm(CurrentDataTable); }
/// <summary> /// Импортирует Excell документ в таблицу /// </summary> /// <param name="Parent">Родительская форма</param> /// <param name="Table">Таблица назначения</param> /// <returns></returns> public static int ImportExcelFile(BankLab Parent, DataGridView Table) { String FileName = Parent.ShowOpenDialog("Файлы Excel (*.xls; *.xlsx)|*.xls;*.xlsx"); if (FileName == String.Empty) { Parent.CurrentProgressBar.HideProgressBar(); return 0; } Excel.Application ExcelApp = new Excel.Application(); ExcelApp.Workbooks.Open(FileName); Table.Visible = false; Parent.CurrentProgressBar.SetProgressBarValue(10); Table = Parent.CurrentDataTable.ReinitializeDataTable(); ExcelFunctions.CreateTemplate(Parent, Table); for (int i = 0; i < ExcelApp.Sheets[1].UsedRange.Rows.Count - 1; i++) { Table.Rows.Add(); for (int j = 1; j <= 18; j++) { Table.Rows[i].Cells[j].Value = ExcelApp.Cells[i + 2, j + 1].Value; } } Parent.CurrentProgressBar.SetProgressBarValue(90); Parent.CurrentDataTable.FillTableIntervalColumnByFirstYear(Convert.ToInt32(ExcelApp.Cells[2, 1].value)); Table.Visible = true; ExcelApp.Workbooks.Close(); ExcelApp.Quit(); Parent.CurrentProgressBar.SetProgressBarValue(100); return 1; }
public save_form(BankLab parent, DataGridView datatable) { InitializeComponent(); Parent = parent; DataTable = datatable; ShowCurrentTableName(); }
public RegressionForm(BankLab parent, ParamForm selectColumnsForm, DataGridView regressionTable) { InitializeComponent(); Parent = parent; SelectColumnsForm = selectColumnsForm; RegressionTable = regressionTable; DefaultHeight = title_label.Height + ButtonPanel.Height; }
public year_form(BankLab parent, bool create) { InitializeComponent(); Create = create; Parent = parent; this.start_year_edit.KeyDown += DelegateButtonsDown; this.end_year_edit.KeyDown += DelegateButtonsDown; }
public coefficient_form(BankLab parent, int index) { InitializeComponent(); this.DoubleBuffered = true; Parent = parent; DefaultHeight = title_label.Height + sub_main_menu.Height + statusStrip1.Height; Index = index; }
public DataBaseEditor(BankLab parent) { InitializeComponent(); Parent = parent; this.FormClosing += CloseDataBaseEditorFormDelegate; }
public static DataGridView StartRegression(bool[] SelectedColumns, BankLab Parent) { Excel.Application ExApp = GetExcelAppWithAddIn(); int ColumnsCount = ExportColumnsToExcel(ExApp, SelectedColumns, Parent); string MacrosCode = "Sub reg()\r\n" + "Application.Run \"ATPVBAEN.XLAM!Regress\", ActiveSheet.Range(\"$A$1:$A$" + Parent.CurrentCoefficientForm.GetCoefficientTable().RowCount.ToString() + "\"), _\r\n" + "ActiveSheet.Range(\"$B$1:$" + (char)((int)'A' + ColumnsCount - 2) + "$" + Parent.CurrentCoefficientForm.GetCoefficientTable().RowCount.ToString() + "\"), False, True, , \"\", False, False, False _\r\n" + ", False, , False\r\n" + "End Sub\r\n"; AddMacros(ExApp, MacrosCode); ExApp.Run("reg"); DataGridView ResTable = ReadResulFromExcel(ExApp, false); ExApp.Workbooks[1].Close(false); ExApp.Workbooks.Close(); ExApp.Quit(); return ResTable; }
private static int ExportColumnsToExcel(Excel.Application exApp, bool[] SelectedColumns, BankLab Parent) { DataGridView Table = Parent.CurrentCoefficientForm.GetCoefficientTable(); int CurColumn = 1; for (int i = 1; i < Table.ColumnCount; i++) { if (SelectedColumns[i - 1]) { exApp.Cells[1, CurColumn] = Table.Columns[i].HeaderText; for (int j = 1; j < Table.RowCount; j++) { exApp.Cells[j + 1, CurColumn].Value = Table.Rows[j].Cells[i].Value; } CurColumn++; } } return CurColumn; }
public forecast_form(BankLab parent) { InitializeComponent(); Parent = parent; }
public open_form(BankLab parent, DataGridView dataTable) { InitializeComponent(); Parent = parent; DataTable = dataTable; }
public OptimizationForm(BankLab parent) { InitializeComponent(); Parent = parent; }