private void PopulateSheetCombo(string filename) { try { excel = new ExcelInteraction(filename); Collection <string> res = excel.GetSheets(); Dispatcher.Invoke(() => { SheetCombo.Items.Clear(); foreach (string o in res) { SheetCombo.Items.Add(o.ToString()); } }); if (Validated == true) { Validated = false; PathButton.IsEnabled = true; } } catch (Exception e) { Dispatcher.Invoke(() => { oFail = new UnableToOpenPopup(this); oFail.Visible = true; SheetCombo.IsEnabled = false; ColCombo.IsEnabled = false; }); } }
private void Button_Click(object sender, RoutedEventArgs e) { if (Started == false) { Started = true; Dispatcher.Invoke(() => { InitialConfig(1); Refresh.IsEnabled = false; }); string SheetComboVal = SheetCombo.SelectedValue.ToString(); string ExcelSheetVal = ExcelCombo.SelectedItem.ToString(); if (excel == null) { excel = new ExcelInteraction(ExcelSheetVal); } try { excel.SetSheetName(SheetComboVal); if (col == 11 || col == 12) { int[] arr = excel.FindStart(RowsAcross, ColsAcross, Attribute); col = arr[1]; row = arr[0]; } else { excel.SetCol(col); } itemCount = excel.GetCount(Attribute); if (itemCount != -1) { Auto_SearchBox.IsEnabled = false; Task t = Task.Factory.StartNew(() => DivvyExcel()); } else { BeginBut.IsEnabled = true; Refresh.IsEnabled = true; fail = new CountFailPopUp(this); fail.Activate(); fail.Visible = true; } } #pragma warning disable CS0168 // Variable is declared but never used catch (Exception ex) #pragma warning restore CS0168 // Variable is declared but never used { oFail = new UnableToOpenPopup(this); oFail.Visible = true; } } }