Esempio n. 1
0
 public void Converter(string _sender, Word.Cells _cells = null, bool other_currency = false, string custom_format = "", double multiplier = 1)
 {
     try
     {
         _cells = Globals.ThisAddIn.Application.Selection.Cells;
         foreach (Word.Cell _cell in _cells)
         {
             String _text     = _cell.Range.Text;
             String hopefully = "";
             Converter_Executor(_sender, _text, out hopefully, other_currency, custom_format, multiplier);
             if (!_text.Equals(hopefully))
             {
                 _cell.Range.Text = hopefully.Trim();
             }
         }
     }
     catch (Exception E)
     {
         System.Windows.Forms.MessageBox.Show("Urgh, this was quite an unexpected error: " + E.Message + ". Sorry for that.", "WooTable .::. Error", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
     }
 }
Esempio n. 2
0
        public string GetWordFileDataMethod(string fileName, out string output1, out string output2,
                                            out string output3, out string output4, out string output5,
                                            out string output6, out string output7, out string output8,
                                            out string output9, out string output10, out string output11,
                                            out string output12, out string output13, out string output14,
                                            out string output15, out string output16)
        {
            Microsoft.Office.Interop.Word.Application app  = new Microsoft.Office.Interop.Word.Application();
            Microsoft.Office.Interop.Word.Documents   docs = app.Documents;
            Microsoft.Office.Interop.Word.Document    doc  = docs.Open(fileName, ReadOnly: true);

            Microsoft.Office.Interop.Word.Table t1     = doc.Tables[1];
            Microsoft.Office.Interop.Word.Range r1     = t1.Range;
            Microsoft.Office.Interop.Word.Cells cells1 = r1.Cells;

            Microsoft.Office.Interop.Word.Table t2     = doc.Tables[2];
            Microsoft.Office.Interop.Word.Range r2     = t2.Range;
            Microsoft.Office.Interop.Word.Cells cells2 = r2.Cells;



            //convert tables to text to get rid of bullet points at the end of text fields
            Regex rg = new Regex("^[A-Za-z0-9/$ !|\\[]{}%&()]$");//regex filter on output text accepting characters alphanumeric and /


            Regex rgg = new Regex("^[A-Za-z0-9/$ .!|\\[]{}%&()]$");//regex filter on output text accepting characters alphanumeric and /

            //if (!rg.IsMatch(cells1[2].Range.Text))
            //{
            //    string employerName = "";
            //}
            //else
            //{
            //    string employerName = rg.Replace(cells1[2].Range.Text, "");
            //}

            //Table 1


            string employerName         = rg.Replace(cells1[2].Range.Text, "");
            string employerID           = rg.Replace(cells1[4].Range.Text, "");
            string region               = rg.Replace(cells1[6].Range.Text, "");
            string segment              = rg.Replace(cells1[8].Range.Text, "");
            string benefitEffectiveDate = rg.Replace(cells1[10].Range.Text, "");
            string currentProducts      = rg.Replace(cells1[12].Range.Text, "");
            string addedProducts        = rg.Replace(cells1[14].Range.Text, "");
            string newImpFlag           = rg.Replace(cells1[16].Range.Text, "");
            string IM_AM       = rg.Replace(cells1[18].Range.Text, "");
            string impDeadline = rg.Replace(cells1[20].Range.Text, "");
            string sftpCreds   = "";

            //Remove MS Word table1 character '•' from the ends of all the text fields

            employerName         = employerName.Remove(employerName.Length - 1, 1);
            employerID           = employerID.Remove(employerID.Length - 1, 1);
            region               = region.Remove(region.Length - 1, 1);
            segment              = segment.Remove(segment.Length - 1, 1);
            benefitEffectiveDate = benefitEffectiveDate.Remove(benefitEffectiveDate.Length - 1, 1);
            currentProducts      = currentProducts.Remove(currentProducts.Length - 1, 1);
            addedProducts        = addedProducts.Remove(addedProducts.Length - 1, 1);
            newImpFlag           = newImpFlag.Remove(newImpFlag.Length - 1, 1);
            IM_AM       = IM_AM.Remove(IM_AM.Length - 1, 1);
            impDeadline = impDeadline.Remove(impDeadline.Length - 1, 1);

            //get rid of carraige return in all fields

            employerName         = employerName.TrimEnd('\r', '\n');
            employerID           = employerID.TrimEnd('\r', '\n');
            region               = region.TrimEnd('\r', '\n');
            segment              = segment.TrimEnd('\r', '\n');
            benefitEffectiveDate = benefitEffectiveDate.TrimEnd('\r', '\n');
            currentProducts      = currentProducts.TrimEnd('\r', '\n');
            addedProducts        = addedProducts.TrimEnd('\r', '\n');
            newImpFlag           = newImpFlag.TrimEnd('\r', '\n');
            IM_AM       = IM_AM.TrimEnd('\r', '\n');
            impDeadline = impDeadline.TrimEnd('\r', '\n');
            sftpCreds   = sftpCreds.TrimEnd('\r', '\n');



            //added field to the implementation table
            if (t1.Rows.Count == 11)
            {
                sftpCreds = rg.Replace(cells1[22].Range.Text, "");
            }
            else if (t1.Rows.Count == 10)
            {
                sftpCreds = string.Empty;
            }



            output1  = employerName;
            output2  = employerID;
            output3  = region;
            output4  = segment;
            output5  = benefitEffectiveDate;
            output6  = currentProducts;
            output7  = addedProducts;
            output8  = newImpFlag;
            output9  = IM_AM;
            output10 = impDeadline;
            output11 = sftpCreds;



            //Table 2


            string contactName        = rgg.Replace(cells2[6].Range.Text, "");
            string contactphoneNumber = rgg.Replace(cells2[7].Range.Text, "");
            string contactEmail       = rgg.Replace(cells2[8].Range.Text, "");
            string contactType        = rgg.Replace(cells2[9].Range.Text, "");
            string fileType           = rgg.Replace(cells2[10].Range.Text, "");

            //Remove MS Word table2 character '•' from the ends of all the text fields

            contactName        = contactName.Remove(contactName.Length - 1, 1);
            contactphoneNumber = contactphoneNumber.Remove(contactphoneNumber.Length - 1, 1);
            contactEmail       = contactEmail.Remove(contactEmail.Length - 1, 1);
            contactType        = contactType.Remove(contactType.Length - 1, 1);
            fileType           = fileType.Remove(fileType.Length - 1, 1);


            //assign output variables
            output12 = contactName;
            output13 = contactphoneNumber;
            output14 = contactEmail;
            output15 = contactType;
            output16 = fileType;



            GetterSetterString getData = new GetterSetterString();

            getData.DataValue = employerName;


            //docs.Close();
            app.Quit();


            return(""); //This is the output door for the outputs to go through
        }
Esempio n. 3
0
        //Инициализация объекта
        public void Init(Word.Row row)
        {
            //Присылается строка таблицы Word из которой получаются ячейки
            Word.Cells cells = row.Cells;

            //У cellsTexts индексация с 0!!! (Мария Холод)
            //var cellsTexts = row.Cells.OfType<Word.Cell>().Select(cell => cell.Range.Text).ToList();

            //Обращение к тексту ячейки: cells[i].Range.Text;

            List <string> cellsTexts = row.Cells.OfType <Word.Cell>().Select(cell => cell.Range.Text).ToList();

            //У cells индексация с 1!!!
            for (int j = 1; j <= cells.Count; j++)
            {
                switch (j)
                {
                //
                case 1:
                {
                    NumPP = clsTextProcessor.WordCellToSum(cells[j].Range.Text);
                    break;
                }

                //
                case 2:
                {
                    NumOUP = clsTextProcessor.WordCellToSum(cells[j].Range.Text);
                    break;
                }

                //
                case 3:
                {
                    Faculty = clsTextProcessor.WordCellToString(cells[j].Range.Text);
                    break;
                }

                //
                case 4:
                {
                    Course = clsTextProcessor.WordCellToSum(cells[j].Range.Text);
                    break;
                }

                //
                case 5:
                {
                    NumOfWeeks = clsTextProcessor.WordCellToSum(cells[j].Range.Text);
                    break;
                }

                //
                case 6:
                {
                    ShortSpecialisation1 = clsTextProcessor.WordCellToString(cells[j].Range.Text);
                    break;
                }

                //
                case 7:
                {
                    ShortSpecialisation2 = clsTextProcessor.WordCellToString(cells[j].Range.Text);
                    break;
                }

                //
                case 8:
                {
                    Students = clsTextProcessor.WordCellToSum(cells[j].Range.Text);
                    break;
                }

                //
                case 9:
                {
                    StudentsFB = clsTextProcessor.WordCellToSum(cells[j].Range.Text);
                    break;
                }

                //
                case 10:
                {
                    Flow = clsTextProcessor.WordCellToSum(cells[j].Range.Text);
                    break;
                }

                //
                case 11:
                {
                    Groups = clsTextProcessor.WordCellToSum(cells[j].Range.Text);
                    break;
                }

                //
                case 12:
                {
                    Discipline = clsTextProcessor.WordCellToString(cells[j].Range.Text);
                    break;
                }

                //
                case 13:
                {
                    LecturesConsult = clsTextProcessor.WordCellToSum(cells[j].Range.Text);
                    break;
                }

                //
                case 14:
                {
                    Exam = clsTextProcessor.WordCellToSum(cells[j].Range.Text);
                    break;
                }

                //
                case 15:
                {
                    Credit = clsTextProcessor.WordCellToSum(cells[j].Range.Text);
                    break;
                }

                // !!!___???___
                case 16:
                {
                    HomeWork = clsTextProcessor.WordCellToSum(cells[j].Range.Text);
                    break;
                }

                //
                case 17:
                {
                    Consultations = clsTextProcessor.WordCellToSum(cells[j].Range.Text);
                    break;
                }

                //
                case 18:
                {
                    LaboratoryWorks = clsTextProcessor.WordCellToSum(cells[j].Range.Text);
                    break;
                }

                //
                case 19:
                {
                    PracticalLess = clsTextProcessor.WordCellToSum(cells[j].Range.Text);
                    break;
                }

                //
                case 20:
                {
                    KSR = clsTextProcessor.WordCellToSum(cells[j].Range.Text);
                    break;
                }

                //
                case 21:
                {
                    TestPK = clsTextProcessor.WordCellToSum(cells[j].Range.Text);
                    break;
                }

                //
                case 22:
                {
                    CourseWork = clsTextProcessor.WordCellToSum(cells[j].Range.Text);
                    break;
                }

                //Тут числа?
                case 23:
                {
                    UndergraduatePract = clsTextProcessor.WordCellToSum(cells[j].Range.Text);
                    break;
                }

                //
                case 24:
                {
                    PreparationVKR = clsTextProcessor.WordCellToSum(cells[j].Range.Text);
                    break;
                }

                //
                case 25:
                {
                    TrainingPract = clsTextProcessor.WordCellToSum(cells[j].Range.Text);
                    break;
                }

                //
                case 26:
                {
                    Internship = clsTextProcessor.WordCellToSum(cells[j].Range.Text);
                    break;
                }

                //Тут числа?
                case 27:
                {
                    StateExam = clsTextProcessor.WordCellToSum(cells[j].Range.Text);
                    break;
                }

                //
                case 28:
                {
                    FederalBudgetZET     = clsTextProcessor.WordCellToSum(cells[j].Range.Text);
                    FederalBudgetZETskob = clsTextProcessor.WordCellToSumSKOB(cells[j].Range.Text);
                    break;
                }

                //
                case 29:
                {
                    TotalZET     = clsTextProcessor.WordCellToSum(cells[j].Range.Text);
                    TotalZETskob = clsTextProcessor.WordCellToSumSKOB(cells[j].Range.Text);
                    break;
                }
                }
            }
        }
        public List <Discipline> ParsePlan()
        {
            List <Discipline> disciplinesCopy = new List <Discipline>(disciplenes);

            //try {
            for (int j = 1; j < table.Count; j++)
            {
                Word.Range range = table[j].Range;
                Word.Cells cells = range.Cells;
                string     key   = "Знать";
                Dictionary <string, List <string> > requirementsForStudent = new Dictionary <string, List <string> >();
                requirementsForStudent.Add("Знать", new List <string>());
                requirementsForStudent.Add("Уметь", new List <string>());
                requirementsForStudent.Add("Владеть", new List <string>());
                string cell1 = cells[1].Range.Text.Trim();
                if (cell1.StartsWith("В результате изучения"))
                {
                    foreach (Discipline disciplene in disciplenes)
                    {
                        if (cells[1].Range.Text.Contains(disciplene.Name))
                        {
                            string temporary = "";
                            for (int i = 1; i <= cells.Count; i++)
                            {
                                Word.Cell  cell        = cells[i];
                                Word.Range updateRange = cell.Range;
                                string     text        = updateRange.Text;
                                text = text.Replace("\v", "");
                                text = text.Replace("\r", "");
                                text = text.Replace("\a", "");
                                text = text.Trim();
                                if (text.ToLower().Equals("знать:"))
                                {
                                    temporary = "знать:";
                                    continue;
                                }
                                else if (text.ToLower().Equals("уметь:"))
                                {
                                    temporary = "уметь:";
                                    continue;
                                }
                                else if (text.ToLower().Equals("владеть:"))
                                {
                                    temporary = "владеть:";
                                    continue;
                                }
                                text = text.Replace(";", "");
                                text = text.Replace(".", "");
                                if (temporary.Equals("знать:"))
                                {
                                    disciplinesCopy.Find(x => x.Name.Equals(disciplene.Name)).RequirementsForStudent["Знать:"].Add(text);
                                }
                                else if (temporary.Equals("уметь:"))
                                {
                                    disciplinesCopy.Find(x => x.Name.Equals(disciplene.Name)).RequirementsForStudent["Уметь:"].Add(text);
                                }
                                else if (temporary.Equals("владеть:"))
                                {
                                    disciplinesCopy.Find(x => x.Name.Equals(disciplene.Name)).RequirementsForStudent["Владеть:"].Add(text);
                                }
                            }
                        }
                    }
                }
            }
            disciplenes = getMethodicalInstructionsForRest(disciplinesCopy);

            WordAPI.Close(doc);
            //}
            //catch (Exception e)
            //{
            //    doc.Close();
            //    new ExceptionWindow()
            //        .Show();
            //}
            return(disciplenes);
        }
        private Dictionary <string, string> FindByRegexTopics(Regex regex, int beginIndex, int endIndex)
        {
            Dictionary <string, string> resultMap = new Dictionary <string, string>();

            try
            {
                Word.Range range          = table.Range;
                Word.Cells cells          = range.Cells;
                string     lastDiscipline = null;
                string     nextDiscipline = null;
                for (int i = beginIndex; i <= endIndex; i++)
                {
                    Word.Cell  cell        = cells[i];
                    Word.Range updateRange = cell.Range;
                    try
                    {
                        if (regex.IsMatch(updateRange.Text))
                        {
                            nextDiscipline = updateRange.Text;
                            if (lastDiscipline == null)
                            {
                                lastDiscipline = nextDiscipline;
                            }
                            if (resultMap.ContainsKey(lastDiscipline) && resultMap[lastDiscipline].IndexOf(',') > 0)
                            {
                                string value;
                                resultMap.TryGetValue(lastDiscipline, out value);
                                value = value.Substring(0, value.IndexOf(','));
                                resultMap[lastDiscipline] = value + "," + i;
                                resultMap.Add(nextDiscipline, i.ToString());
                            }
                            else if (resultMap.ContainsKey(lastDiscipline))
                            {
                                string value;
                                resultMap.TryGetValue(lastDiscipline, out value);
                                resultMap[lastDiscipline] = value + "," + i;
                                resultMap.Add(nextDiscipline, i.ToString());
                            }
                            else
                            {
                                resultMap.Add(nextDiscipline, i.ToString());
                            }
                        }
                        lastDiscipline = nextDiscipline;
                    }
                    catch (Exception e)
                    {
                    }
                }
                string lastValue;
                resultMap.TryGetValue(lastDiscipline, out lastValue);
                resultMap[lastDiscipline] = lastValue + "," + endIndex;
            }
            catch (Exception e)
            {
                doc.Close();
                new ExceptionWindow()
                .Show();
            }
            return(resultMap);
        }
        private List <Lesson> GetLessonsByTopic(KeyValuePair <string, string> topic)
        {
            List <Lesson> lessons              = new List <Lesson>();
            string        kindOfLesson         = "";
            string        minutes              = "";
            string        questionsOfLesson    = "";
            string        materialSupport      = "";
            string        lessonInMaterialSupp = "";
            string        themeOfLesson        = "";
            List <string> questions            = new List <string>();
            string        literature           = "";

            Word.Range range = table.Range;
            Word.Cells cells = range.Cells;
            Regex      regex = new Regex(@"^Лекция|^Самостоя|^Группов|^Практичес|^Трениров");

            char[] charsToTrim = { '\a', '\r' };

            for (int i = Int32.Parse(topic.Value.Substring(0, topic.Value.IndexOf(','))) + 1; i < Int32.Parse(topic.Value.Substring(topic.Value.IndexOf(',') + 1)); i++)
            {
                Word.Cell  cell        = cells[i];
                Word.Range updateRange = cell.Range;
                string     text        = updateRange.Text;
                if (regex.IsMatch(text))
                {
                    kindOfLesson = text.Trim(charsToTrim);
                    kindOfLesson = kindOfLesson.Replace("\r", "");
                    //get count of hours
                    cell = cells[i + 1];
                    if (cell.Range.Text.Length > 0)
                    {
                        minutes = cell.Range.Text.Trim(charsToTrim);
                    }
                    //get questions of the lesson
                    cell = cells[i + 2];
                    questionsOfLesson = cell.Range.Text.Trim(charsToTrim);
                    int a = questionsOfLesson.IndexOf("«");
                    if (questionsOfLesson.IndexOf("«") > 20)
                    {
                        lessonInMaterialSupp = "Ошибка в темплане";
                        themeOfLesson        = "Ошибка в темплане";
                        questions            = getQuestions(questionsOfLesson);
                    }
                    else
                    {
                        lessonInMaterialSupp = questionsOfLesson.Substring(0, questionsOfLesson.IndexOf("«"));
                        try
                        {
                            themeOfLesson = questionsOfLesson.Substring(questionsOfLesson.IndexOf("«"), questionsOfLesson.IndexOf("»") - questionsOfLesson.IndexOf("«") + 1);
                        }
                        catch (Exception e)
                        {
                            themeOfLesson = questionsOfLesson.Substring(questionsOfLesson.IndexOf("«"), questionsOfLesson.IndexOf(".") - questionsOfLesson.IndexOf("«") + 1);
                        }
                        questions = getQuestions(questionsOfLesson.Substring(questionsOfLesson.IndexOf("«")));
                    }

                    //get material support
                    cell            = cells[i + 3];
                    materialSupport = cell.Range.Text.Trim(charsToTrim);

                    //get literature
                    cell       = cells[i + 4];
                    literature = cell.Range.Text.Trim(charsToTrim);

                    //get hours if first cell was empty
                    if (minutes == "")
                    {
                        cell    = cells[i + 5];
                        minutes = cell.Range.Text.Trim(charsToTrim);
                    }
                    Lesson lesson = new Lesson();
                    lesson.Type = kindOfLesson;
                    if (kindOfLesson.Contains("1"))
                    {
                        lesson.NumberLessom = "з1";
                    }
                    else if (kindOfLesson.Contains("2"))
                    {
                        lesson.NumberLessom = "з2";
                    }
                    else if (kindOfLesson.Contains("3"))
                    {
                        lesson.NumberLessom = "з3";
                    }
                    else if (kindOfLesson.Contains("4"))
                    {
                        lesson.NumberLessom = "з4";
                    }
                    else if (kindOfLesson.Contains("5"))
                    {
                        lesson.NumberLessom = "з5";
                    }
                    else if (kindOfLesson.Contains("6"))
                    {
                        lesson.NumberLessom = "з6";
                    }
                    else if (kindOfLesson.Contains("7"))
                    {
                        lesson.NumberLessom = "з7";
                    }
                    else if (kindOfLesson.Contains("8"))
                    {
                        lesson.NumberLessom = "з8";
                    }
                    else if (kindOfLesson.Contains("9"))
                    {
                        lesson.NumberLessom = "з9";
                    }
                    else if (kindOfLesson.Contains("10"))
                    {
                        lesson.NumberLessom = "з10";
                    }
                    else if (kindOfLesson.Contains("11"))
                    {
                        lesson.NumberLessom = "з11";
                    }
                    else if (kindOfLesson.Contains("12"))
                    {
                        lesson.NumberLessom = "з12";
                    }
                    else if (kindOfLesson.Contains("13"))
                    {
                        lesson.NumberLessom = "з13";
                    }
                    else if (kindOfLesson.Contains("14"))
                    {
                        lesson.NumberLessom = "з14";
                    }
                    else
                    {
                        lesson.NumberLessom = "з15";
                    }
                    lesson.Literature           = literature;
                    lessonInMaterialSupp        = lessonInMaterialSupp.Trim();
                    lessonInMaterialSupp        = lessonInMaterialSupp.Replace("\r", "");
                    lessonInMaterialSupp        = lessonInMaterialSupp.Replace("\a", "");
                    lesson.LessonInMaterialSupp = lessonInMaterialSupp;
                    lesson.ThemeOfLesson        = themeOfLesson;
                    lesson.Questions            = questions;
                    materialSupport             = materialSupport.Trim();
                    materialSupport             = materialSupport.Replace("\r", "");
                    materialSupport             = materialSupport.Replace("\a", "");
                    lesson.MaterialSupport      = materialSupport;
                    //ПРО САМОСТОЯТЕЛЬНУ РАБОТУ СПРОСИТЬ СКОЛЬКО ТАМ МИНУТ БУДЕТ
                    if (lesson.Type.Contains("Лекци") || lesson.Type.Contains("Групповое") || lesson.Type.Contains("Практичес") || lesson.Type.Contains("Самосто"))
                    {
                        try
                        {
                            int count = Int32.Parse(minutes) * 45;
                            minutes = count.ToString();
                        }
                        catch (Exception e)
                        {
                            minutes = "Не было указано в темплане!";
                        }
                    }
                    else if (lesson.Type.Contains("Трениров"))
                    {
                        minutes = "30";
                    }
                    lesson.Minutes = minutes;
                    lessons.Add(lesson);
                    i += 5;
                }
            }

            return(lessons);
        }
        //find all discipline in file and return map where key is name of discipline and value is string with begin and end index of discipline(separated with ,)
        private Dictionary <string, string> FindByRegexDisciplin(params Regex[] regexs)
        {
            Dictionary <string, string> resultMap = new Dictionary <string, string>();

            try {
                Word.Range range          = table.Range;
                Word.Cells cells          = range.Cells;
                string     lastDiscipline = null;
                string     nextDiscipline = null;
                for (int i = 1; i <= cells.Count; i++)
                {
                    Word.Cell  cell        = cells[i];
                    Word.Range updateRange = cell.Range;
                    try
                    {
                        foreach (Regex re in regexs)
                        {
                            if (re.IsMatch(updateRange.Text))
                            {
                                nextDiscipline = updateRange.Text.Substring(0, updateRange.Text.Length);
                                nextDiscipline = nextDiscipline.Trim();
                                nextDiscipline = nextDiscipline.Replace("\v", "");
                                nextDiscipline = nextDiscipline.Replace("\r", "");
                                nextDiscipline = nextDiscipline.Replace("\a", "");
                                nextDiscipline = nextDiscipline.Replace("  ", " ");
                                if (lastDiscipline == null)
                                {
                                    lastDiscipline = nextDiscipline;
                                }
                                if (resultMap.ContainsKey(lastDiscipline))
                                {
                                    string value;
                                    resultMap.TryGetValue(lastDiscipline, out value);
                                    if (value.IndexOf(',') > 0)
                                    {
                                        value = value.Substring(0, value.IndexOf(','));
                                        resultMap[lastDiscipline] = value + "," + i;
                                        resultMap.Add(nextDiscipline, i.ToString());
                                    }
                                    else
                                    {
                                        resultMap[lastDiscipline] = value + "," + i;
                                        resultMap.Add(nextDiscipline, i.ToString());
                                    }
                                }
                                else
                                {
                                    resultMap.Add(nextDiscipline, i.ToString());
                                }
                            }
                            lastDiscipline = nextDiscipline;
                        }
                    }
                    catch (Exception e)
                    {
                    }
                }
                string lastValue = null;
                if (lastDiscipline == null)
                {
                    foreach (Word.Paragraph paragraph in doc.Paragraphs)
                    {
                        Regex  regex1 = new Regex(@"^*ОВП*");
                        Regex  regex2 = new Regex(@"^*ОГП*");
                        Regex  regex3 = new Regex(@"^*ВТП*");
                        string text   = paragraph.Range.Text;
                        if (regex1.IsMatch(text))
                        {
                            text = text.Substring(text.IndexOf("OВП")).Trim();
                            resultMap.Add(text, "9," + (cells.Count - 1));
                            return(resultMap);
                        }
                        if (regex2.IsMatch(text))
                        {
                            text = text.Substring(text.IndexOf("OГП")).Trim();
                            resultMap.Add(text, "9," + (cells.Count - 1));
                            return(resultMap);
                        }
                        if (regex3.IsMatch(text))
                        {
                            text = text.Substring(text.IndexOf("ВТП")).Trim();
                            resultMap.Add(text, "9," + (cells.Count - 1));
                            return(resultMap);
                        }
                    }
                }
                resultMap.TryGetValue(lastDiscipline, out lastValue);
                if (lastValue.IndexOf(',') > 0)
                {
                    lastValue = lastValue.Substring(0, lastValue.IndexOf(','));
                    resultMap[lastDiscipline] = lastValue + "," + (cells.Count - 1);
                }
                else
                {
                    resultMap[lastDiscipline] = lastValue + "," + (cells.Count - 1);
                }
            }
            catch (Exception e)
            {
                doc.Close();
                new ExceptionWindow()
                .Show();
            }
            return(resultMap);
        }