コード例 #1
0
        private void ReadSheetNames()
        {
            SheetNames.Clear();
            SelectedSheetName = string.Empty;

            try {
                ExcelReader.ReadSheetNames(selectedFile).ForEach(SheetNames.Add);

                if (SheetNames.Count > 0)
                {
                    if (SheetNames.Contains("Лист1"))
                    {
                        SelectedSheetName = "Лист1";
                    }
                    else if (SheetNames.Contains("Данные"))
                    {
                        SelectedSheetName = "Данные";
                    }
                    else
                    {
                        SelectedSheetName = SheetNames[0];
                    }
                }
            } catch (Exception exc) {
                MessageBox.Show(
                    this,
                    exc.Message + Environment.NewLine + exc.StackTrace,
                    "Ошибка считывания Excel файла",
                    MessageBoxButton.OK,
                    MessageBoxImage.Error);
            }
        }
コード例 #2
0
 private void OnSelectedSheetChanged()
 {
     if (string.IsNullOrEmpty(SelectedSheet))
     {
         IsValid = false;
     }
     if (!SheetNames.Contains(SelectedSheet))
     {
         IsValid = false;
     }
     IsValid = true;
 }