private void AddClient_Load(object sender, EventArgs e) { textBox4.Text = (ClientFactory.count() + 1).ToString(); for (int i = 0; i < ClientTypeCol.count(); i++) { comboBox1.Items.Add(ClientTypeCol.coll_of_type[i].Type); } }
static public void openData() { string filename = "E:\\Shop\\Данные\\Clients.xlsx"; Microsoft.Office.Interop.Excel.Application ExcelApp = new Microsoft.Office.Interop.Excel.Application(); Microsoft.Office.Interop.Excel._Workbook ExcelWorkBook; Microsoft.Office.Interop.Excel.Worksheet ExcelWorkSheet; ExcelWorkBook = ExcelApp.Workbooks.Open(filename, 0, true, 5, "", "", true, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0); ExcelWorkSheet = (Microsoft.Office.Interop.Excel.Worksheet)ExcelWorkBook.Worksheets.get_Item(1); int i = 1; int flag = 0; while (true) { dataClients.Rows.Add(1); for (int j = 1; j <= dataClients.ColumnCount; j++) { dataClients.Rows[i - 1].Cells[j - 1].Value = ExcelApp.Cells[i, j].Value; if (dataClients.Rows[i - 1].Cells[0].Value == null) { flag = 1; dataClients.Rows.RemoveAt(i - 1); break; } } if (flag == 1) { break; } ++i; } ClientTypeCol col = new ClientTypeCol(); ClientFactory obj = new ClientFactory(); }