private void btnChonFile_Click(object sender, EventArgs e) { Excel.Application ExcelObj = new Excel.Application(); OpenFileDialog dlg = new OpenFileDialog(); dlg.Filter = "Excel files|*.xls; *.xlsx"; if (dlg.ShowDialog() == DialogResult.OK) { Excel.Workbook theWorkbook = ExcelObj.Workbooks.Open(dlg.FileName, 0, true, 5, "", "", true, Excel.XlPlatform.xlWindows, "\t", false, false, 0, true); Excel.Sheets sheets = theWorkbook.Worksheets; Excel.Worksheet worksheet = (Excel.Worksheet)sheets.get_Item(1); Excel.Range UsedRange = worksheet.UsedRange; int lastUsedRow = UsedRange.Row + UsedRange.Rows.Count - 1; for (int i = 2; i <= lastUsedRow; i++) { Excel.Range range = worksheet.get_Range("A" + i.ToString(), "C" + i.ToString()); System.Array value = (System.Array)range.Cells.Value; string[] strArray = ConvertToStringArray(value); string Quyen = strArray[2]; bool check = (Quyen != "Quản trị hệ thống" && Quyen != "Khác" && Quyen != "Nhân viên" && Quyen != "Quản lý"); if (!bllND.CheckTrungTenDN(strArray[0]) && !CheckTrungListViewTK(strArray[0]) && check) { listViewTK.Items.Add(new ListViewItem(strArray)); } } } lbTBThemTK.Visible = false; }