Exemplo n.º 1
2
        public HumanMacroDialog(Word.Range text, int jobNumber)
        {
            this.text = text;
            this.jobNumber = jobNumber;
            InitializeComponent();

            Binding binding = new Binding();
            binding.Source = text;
            binding.Path = new PropertyPath("Text");
            textToWorkWith.SetBinding(TextBox.TextProperty, binding);

            numItems.Content = numSections + " paragraph" + (numSections == 1 ? "" : "s") + " selected, each as a separate task";

            item1 = new ComboBoxItem();
            item1.Content = "Paragraph";
            item2 = new ComboBoxItem();
            item2.Content = "Sentence";

            separatorBox.Items.Add(item1);
            separatorBox.Items.Add(item2);
            separatorBox.SelectedValue = item1;

            returnAsComments = new ComboBoxItem();
            returnAsComments.Content = "Comments";
            returnAsInline = new ComboBoxItem();
            returnAsInline.Content = "In-Line Changes";
            returnTypeBox.Items.Add(returnAsComments);
            returnTypeBox.Items.Add(returnAsInline);
            returnTypeBox.SelectedValue = returnAsComments;
        }
Exemplo n.º 2
0
 /// <summary>
 /// コンストラクタ
 /// </summary>
 public RevPos()
 {
     fStart = new Position(0, 0);
     fEnd = new Position(0, 0);
     fRange = null;
     fKind = KIND.TEXT;//デフォルト
 }
Exemplo n.º 3
0
        public void FindAndReplace(string findText, string replaceText)
        {
            // обьектные строки для Word
            object strToFindObj ="{"+findText+"}";
            object replaceStrObj = replaceText;

            //тип поиска и замены
            object replaceTypeObj;
            replaceTypeObj = Word.WdReplace.wdReplaceAll;

            // обходим все разделы документа
            for (int i = 1; i <= document.Sections.Count; i++)
            {

                // берем всю секцию диапазоном
                wordRange = document.Sections[i].Range;

                Word.Find wordFindObj = wordRange.Find;

                object[] wordFindParameters = new object[15] { strToFindObj, missingObj, missingObj, missingObj, missingObj, missingObj, missingObj, missingObj, missingObj, replaceStrObj, replaceTypeObj, missingObj, missingObj, missingObj, missingObj };

                wordFindObj.GetType().InvokeMember("Execute", BindingFlags.InvokeMethod, null, wordFindObj, wordFindParameters);

            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// A superclass that represents the Model for an individual HIT.
        /// </summary>
        /// <param name="range">The Range object selected for this task</param>
        /// <param name="job">The unique job number for this task</param>
        public HITData(Word.Range range, int job)
        {
            this.range = range;
            this.job = job;
            int unixTime = (int)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds;
            string bookmarkName = "Soylent" + job;
            this.stages = new List<StageData>();

            numParagraphs = range.Paragraphs.Count;

            //stages = new Dictionary<ResultType, StageData>();
            //TODO: Use Word XML binding to text instead of bookmarks.
            /*
             * Improved Data Mapping Provides Separation Between a Document's Data and Its Formatting
             *  XML mapping allows you to attach XML data to Word documents and link XML elements to placeholders in the document.
             *  Combined with content controls, XML mapping becomes a powerful tool for developers.
             *  These features provide you with the capability to position content controls in the document and then link them to XML elements.
             *  This type of data and view separation allows you to access Word document data to repurpose and integrate with other systems and applications.
             */

            object bkmkRange = (object)range;
            Globals.Soylent.jobToDoc[this.job].Bookmarks.Add(bookmarkName, ref bkmkRange);

            tk = new TurKit(this);
        }
Exemplo n.º 5
0
 public HITData()
 {
     this.range = null;
     this.job = -1;
     numParagraphs = 0;
     this.stages = new List<StageData>();
     tk = new TurKit(this);
 }
Exemplo n.º 6
0
 public DomIter(Word.Range doc)
 {
     if (doc.Paragraphs.Count == 0)
     {
         throw new InvalidOperationException("Don't know how to handle a document with no paragraphs");
     }
     _count = doc.Paragraphs.Count;
     _document = doc;
     _index = 0;
 }
Exemplo n.º 7
0
 public MarkupStruct(String originalStr, String markedStr, Word.Range rngCita, Boolean marked, Boolean parsed)
 {
     this.originalStr = originalStr;
     /* Creando string rtf */
     this.markedRtb = new RichTextBox();
     this.markedRtb.DetectUrls = false;
     this.markedRtb.Text = markedStr;
     this.marked = marked;
     this.parsed = parsed;
     this.rngCita = rngCita;
 }
Exemplo n.º 8
0
        /// <summary>
        /// コンストラクタ
        /// </summary>
        /// <param name="start">変更箇所の開始位置</param>
        /// <param name="end">変更箇所の終了位置</param>
        /// <param name="rng">レンジ・インスタンス</param>
        /// <param name="kind">変更の種類</param>
        public RevPos(Position start, Position end, Word.Range rng, KIND kind)
        {
            if (start >= end) {
                throw new ArgumentOutOfRangeException(
                    this.GetType().FullName + "." + MethodBase.GetCurrentMethod().Name);
            }

            fStart = start;
            fEnd = end;
            fRange = rng;
            fKind = kind;
        }
Exemplo n.º 9
0
        //public HumanMacroData(Word.Range text, List<String> results)
        public HumanMacroData(Word.Range toShorten, int job, Separator separator, double reward, int redundancy, string title, string subtitle, string instructions, ReturnType type, TestOrReal test)
            : base(toShorten, job)
        {
            this.text = toShorten;
            this.separator = separator;
            //this.results = results;
            //patches = new List<HumanMacroPatch>();

            this.reward = reward;
            this.redundancy = redundancy;
            this.title = title;
            this.subtitle = subtitle;
            this.instructions = instructions;
            this.type = type;
            this.numberReturned = 0;
            this.test = test;

            //stages[HITData.ResultType.Macro] = new StageData(HITData.ResultType.Macro);
            macroStageData = new StageData(HITData.ResultType.Macro, job);
            stages.Add(macroStageData);
            //stages[HITData.ResultType.Macro] = new HumanMacroStage(HITData.ResultType.Macro, redundancy);

            results = new List<string>();
        }
Exemplo n.º 10
0
        public void SaveWordTable(string filename)
        {
            Word.Application wdApp = new Word.Application();
            Word.Document    doc   = wdApp.Documents.Add();

            //Добавляем таблицу в начало второго параграфа
            Object defaultTableBehavior =
                Word.WdDefaultTableBehavior.wdWord9TableBehavior;
            Object autoFitBehavior =
                Word.WdAutoFitBehavior.wdAutoFitWindow;

            Word.Paragraph dhp  = doc.Paragraphs.Add();
            Word.Range     d    = dhp.Range;
            Word.Table     Bank = doc.Content.Tables.Add(d, data.Banks.Count + 1, 6, ref defaultTableBehavior, ref autoFitBehavior);
            Bank.Borders.Enable = 1;
            Bank.Rows[1].Cells[1].Range.Text = "Название";
            Bank.Rows[1].Cells[2].Range.Text = "Mfo";
            Bank.Rows[1].Cells[3].Range.Text = "Address";
            Bank.Rows[1].Cells[4].Range.Text = "Type";
            Bank.Rows[1].Cells[5].Range.Text = "PhoneNumber";
            int i = 2;

            foreach (Data.Bank dh in data.Banks)
            {
                Bank.Rows[i].Cells[1].Range.Text = dh.BankName;
                Bank.Rows[i].Cells[2].Range.Text = dh.MFO.ToString();
                Bank.Rows[i].Cells[3].Range.Text = dh.Adress.ToString();
                Bank.Rows[i].Cells[4].Range.Text = dh.BankType.ToString();
                Bank.Rows[i].Cells[5].Range.Text = dh.NumberPhone.ToString();
                i++;
            }
            //Сдвигаемся вниз в конец документа
            object unit;
            object extend;

            unit   = Word.WdUnits.wdStory;
            extend = Word.WdMovementType.wdMove;
            wdApp.Selection.EndKey(ref unit, ref extend);

            Word.Paragraph ihp = doc.Paragraphs.Add();
            Word.Range     ing = ihp.Range;

            Word.Table Currency = doc.Content.Tables.Add(ing, data.Types.Count + 1, 4, ref defaultTableBehavior, ref autoFitBehavior);
            Currency.Borders.Enable = 1;
            Currency.Rows[1].Cells[1].Range.Text = "Название";
            Currency.Rows[1].Cells[2].Range.Text = "Номер";
            Currency.Rows[1].Cells[3].Range.Text = "Сокращение";
            i = 2;
            foreach (Data.Type dh in data.Types)
            {
                Currency.Rows[i].Cells[1].Range.Text = dh.NameOfCurrency;
                Currency.Rows[i].Cells[2].Range.Text = dh.NumbOfCurrency.ToString();
                Currency.Rows[i].Cells[3].Range.Text = dh.ShortNameOfCurrency.ToString();
                i++;
            }
            //Сдвигаемся вниз в конец документа
            object unit1;
            object extend1;

            unit1   = Word.WdUnits.wdStory;
            extend1 = Word.WdMovementType.wdMove;
            wdApp.Selection.EndKey(ref unit1, ref extend1);

            Word.Paragraph chp      = doc.Paragraphs.Add();
            Word.Range     cng      = chp.Range;
            Word.Table     LogEntry = doc.Content.Tables.Add(cng, data.Logs.Count + 1, 5, ref defaultTableBehavior, ref autoFitBehavior);
            LogEntry.Borders.Enable = 1;
            LogEntry.Rows[1].Cells[1].Range.Text = "MFO";
            LogEntry.Rows[1].Cells[2].Range.Text = "Валюта";
            LogEntry.Rows[1].Cells[3].Range.Text = "Date";
            LogEntry.Rows[1].Cells[4].Range.Text = "SalesRate";
            LogEntry.Rows[1].Cells[5].Range.Text = "PurchaseRate";
            i = 2;
            foreach (Data.Log dh in data.Logs)
            {
                LogEntry.Rows[i].Cells[1].Range.Text = dh.MFO.ToString();
                LogEntry.Rows[i].Cells[2].Range.Text = dh.NumbOfCurrency.ToString();
                LogEntry.Rows[i].Cells[3].Range.Text = dh.Date.ToString();
                LogEntry.Rows[i].Cells[4].Range.Text = dh.SaleCurrency.ToString();
                LogEntry.Rows[i].Cells[5].Range.Text = dh.BuyCurrency.ToString();
                i++;
            }

            doc.SaveAs(filename);
            doc.Close();
            wdApp.Quit();
            ReleaseObject(Bank);
            ReleaseObject(Currency);
            ReleaseObject(LogEntry);
            ReleaseObject(doc);
            ReleaseObject(wdApp);
        }
Exemplo n.º 11
0
        void GetClipboardData()
        {
            try
            {
                IDataObject iData = new DataObject();
                iData = Clipboard.GetDataObject();

                if (iData.GetDataPresent(DataFormats.Text))
                {
                    //Enable if need to see text...
                    //txtMain.Text = (string)iData.GetData(DataFormats.Text);


                    string t = (string)iData.GetData(DataFormats.Text);
                    if (t.IndexOf(keyword) == 0)
                    {
                        //we get the clean url
                        t = GetURL(t);

                        IntPtr hwnd = FindWindowByCaption(IntPtr.Zero, rdp.MainWindowTitle);

                        ShowWindow(hwnd, SW_MINIMIZE);
                        Process.Start(t);
                    }
                    else if (t.IndexOf(mkeyword) == 0)
                    {
                        //we process that string into an object
                        MailInfo mInfo = new MailInfo(t);

                        IntPtr hwnd = FindWindowByCaption(IntPtr.Zero, rdp.MainWindowTitle);

                        //minimize rdp
                        ShowWindow(hwnd, SW_MINIMIZE);

                        //OUTLOOK PROCESS HERE!
                        //we load the template path
                        string template = CMSettings.Default.TemplateLocation;

                        //here we create an Outlook App instance to create a new mailitem from template
                        Outlook.Application oApp  = new Outlook.Application();
                        Outlook.MailItem    nMail = oApp.CreateItemFromTemplate(template) as Outlook.MailItem;
                        //Outlook.MailItem nMail = oApp.CreateItemFromTemplate(@"C:\Users\Alex Castro\AppData\Roaming\Microsoft\Templates\Ticket Request.oft") as Outlook.MailItem;

                        nMail.To = mInfo.Email;

                        //after assigning the email to the "To" bit, we open
                        //a word document to edit the body. Why a word doc?
                        //Because we lose the template formatting otherwise!
                        Word.Document doc = new Word.Document();
                        doc = nMail.GetInspector.WordEditor as Word.Document;
                        Word.Range fRng = doc.Range();

                        while (fRng.Find.Execute(FindText: "…,"))
                        {
                            fRng.Text = $"{mInfo.Name},";
                            fRng.Collapse(0);
                        }
                        while (fRng.Find.Execute(FindText: "* … *"))
                        {
                            fRng.Text = $"* {mInfo.ID} *";
                            fRng.Collapse(0);
                        }

                        nMail.Display();
                    }
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
            }
        }
Exemplo n.º 12
0
        private void btnOpenWorld_Click(object sender, EventArgs e)
        {
            //make a word obj
            Microsoft.Office.Interop.Word.Application word = new Microsoft.Office.Interop.Word.Application();

            //make new doc
            Document doc = word.Documents.Add();

            Microsoft.Office.Interop.Word.Range rng = doc.Range(0, 0);

            //makes new table based on datagridview
            Table wdTable = doc.Tables.Add(rng, dataGridView1.Rows.Count, dataGridView1.Columns.Count);

            //make thick outer border
            wdTable.Borders.OutsideLineStyle = WdLineStyle.wdLineStyleDouble;

            //make cell lines thin
            wdTable.Borders.InsideLineStyle = WdLineStyle.wdLineStyleSingle;

            try
            {
                //make active doc in word
                doc = word.ActiveDocument;

                //i is row index
                for (int i = 0; i < dataGridView1.Rows.Count - 1; i++)
                {
                    //j is column index
                    for (int j = 0; j < dataGridView1.Columns.Count; j++)
                    {
                        //rows several times and writes cell value from grid to word
                        if (i == 0)
                        {
                            wdTable.Cell(i + 1, j + 1).Range.InsertAfter(dataGridView1.Columns[j].HeaderText);
                        }
                        else
                        {
                            wdTable.Cell(i + 1, j + 1).Range.InsertAfter(dataGridView1.Rows[i].Cells[j].Value.ToString());
                        }
                    }
                }

                if (saveFileDialog1.ShowDialog() == DialogResult.OK)
                {
                    try
                    {
                        //saves file to drive
                        doc.SaveAs(saveFileDialog1.FileName);

                        //open doc in word
                        Process.Start("winword.exe", saveFileDialog1.FileName);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            finally
            {
                //quite world
                word.Quit();
                word = null;

                //clean up world obj & doc obj
                doc = null;
            }
        }
Exemplo n.º 13
0
        public void Export_Data_To_Word(DataGridView DGV, string filename)
        {
            if (DGV.Rows.Count != 0)
            {
                int RowCount    = DGV.Rows.Count;
                int ColumnCount = DGV.Columns.Count;
                Object[,] DataArray = new object[RowCount + 1, ColumnCount + 1];

                //add rows
                int r = 0;
                for (int c = 0; c <= ColumnCount - 1; c++)
                {
                    for (r = 0; r <= RowCount - 1; r++)
                    {
                        DataArray[r, c] = DGV.Rows[r].Cells[c].Value;
                    } //end row loop
                }     //end column loop

                Word.Document oDoc = new Word.Document();
                oDoc.Application.Visible    = true;
                oDoc.PageSetup.TopMargin    = 4f;
                oDoc.PageSetup.BottomMargin = 4f;
                oDoc.PageSetup.LeftMargin   = 4f;
                oDoc.PageSetup.RightMargin  = 4f;

                //page orintation
                oDoc.PageSetup.Orientation = Word.WdOrientation.wdOrientLandscape;


                dynamic oRange = oDoc.Content.Application.Selection.Range;
                string  oTemp  = "";
                for (r = 0; r <= RowCount - 1; r++)
                {
                    for (int c = 0; c <= ColumnCount - 1; c++)
                    {
                        oTemp = oTemp + DataArray[r, c] + "\t";
                    }
                }

                //table format
                oRange.Text = oTemp;

                object Separator       = Word.WdTableFieldSeparator.wdSeparateByTabs;
                object ApplyBorders    = true;
                object AutoFit         = true;
                object AutoFitBehavior = Word.WdAutoFitBehavior.wdAutoFitWindow;

                oRange.ConvertToTable(ref Separator, ref RowCount, ref ColumnCount,
                                      Type.Missing, Type.Missing, ref ApplyBorders,
                                      Type.Missing, Type.Missing, Type.Missing,
                                      Type.Missing, Type.Missing, Type.Missing,
                                      Type.Missing, ref AutoFit, ref AutoFitBehavior, Type.Missing);

                oRange.Select();

                oDoc.Application.Selection.Tables[1].Select();
                oDoc.Application.Selection.Tables[1].Rows.AllowBreakAcrossPages = 0;
                oDoc.Application.Selection.Tables[1].Rows.Alignment             = 0;
                oDoc.Application.Selection.Tables[1].Rows[1].Select();
                oDoc.Application.Selection.InsertRowsAbove(1);
                oDoc.Application.Selection.Tables[1].Rows[1].Select();
                //header row style
                oDoc.Application.Selection.Tables[1].Rows[1].Range.Bold       = 1;
                oDoc.Application.Selection.Tables[1].Rows[1].Range.Font.Name  = "Tahoma";
                oDoc.Application.Selection.Tables[1].Rows[1].Range.Font.Size  = 7;
                oDoc.Application.Selection.Tables[1].Borders.OutsideLineStyle =
                    Word.WdLineStyle.wdLineStyleSingle;
                oDoc.Application.Selection.Tables[1].Borders.InsideLineStyle =
                    Word.WdLineStyle.wdLineStyleSingle;
                oDoc.Application.Selection.Tables[1].Borders.OutsideLineWidth = Word.WdLineWidth.wdLineWidth025pt;
                oDoc.Application.Selection.Tables[1].Borders.InsideLineWidth  = Word.WdLineWidth.wdLineWidth025pt;

                //add header row manually
                for (int c = 0; c <= ColumnCount - 1; c++)
                {
                    oDoc.Application.Selection.Tables[1].Cell(1, c + 1).Range.Text = DGV.Columns[c].HeaderText;
                }

                //table style
                oDoc.Application.Selection.Tables[1].Rows[1].Select();
                oDoc.Application.Selection.Cells.VerticalAlignment = Word.WdCellVerticalAlignment.wdCellAlignVerticalCenter;

                var plan = Program.Db.Plans.Find(primaryKey);
                var loc  = plan.Locality.Name;

                var m = new []
                {
                    "Январь",
                    "Февраль",
                    "Март",
                    "Апрель",
                    "Май",
                    "Июнь",
                    "Июль",
                    "Август",
                    "Сентябрь",
                    "Октябрь",
                    "Ноябрь",
                    "Декабрь",
                };

                //header text
                foreach (Word.Section section in oDoc.Application.ActiveDocument.Sections)
                {
                    Word.Range headerRange = section.Headers[Word.WdHeaderFooterIndex.wdHeaderFooterPrimary].Range;
                    headerRange.Fields.Add(headerRange, Word.WdFieldType.wdFieldPage);
                    headerRange.Text      = $"План-график за '{m[plan.Month - 1]} {plan.Year}' на '{loc}'";
                    headerRange.Font.Size = 16;
                    headerRange.ParagraphFormat.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;
                }

                //save the file
                oDoc.Application.Selection.Tables[1].Columns[1].Width = 200f;
                oDoc.Application.Selection.Tables[1].Columns.AutoFit();
                oDoc.SaveAs2(filename);
            }
        }
Exemplo n.º 14
0
        public static void ExportWordData(DataTable wordData, DataTable textData, DataTable classTable, DateTime PeriodDateFrom, DateTime PeriodDateTo, DataTable CHLDReport)
        {
            try
            {
                _Word._Application WordApp = new _Word.Application();
                _Word._Document    WordDoc = new _Word.Document();

                object oMissing  = Missing.Value;
                object oEndOfDoc = "\\endofdoc";

                WordDoc = WordApp.Documents.Add(ref oMissing, ref oMissing, ref oMissing, ref oMissing);

                _Word.Paragraph oPara1;
                oPara1 = WordDoc.Content.Paragraphs.Add(ref oMissing);

                if (PeriodDateFrom.ToString("MMMMyyyy") == PeriodDateTo.ToString("MMMMyyyy"))
                {
                    oPara1.Range.Text = $"Информация о детях, обратившихся за медицинской помощью в медицинские организации Краснодарского края из оздоровительных организаций всех форм собственности Краснодарского края за {PeriodDateTo:MMMM yyyy}";
                }
                else if (PeriodDateFrom.ToString("yyyy") == PeriodDateTo.ToString("yyyy"))
                {
                    oPara1.Range.Text = $"Информация о детях, обратившихся за медицинской помощью в медицинские организации Краснодарского края из оздоровительных организаций всех форм собственности Краснодарского края за {PeriodDateFrom:MMMM}-{PeriodDateTo:MMMM yyyy}";
                }
                else
                {
                    oPara1.Range.Text = $"Информация о детях, обратившихся за медицинской помощью в медицинские организации Краснодарского края из оздоровительных организаций всех форм собственности Краснодарского края за {PeriodDateFrom:MMMM yyyy}-{PeriodDateTo:MMMM yyyy}";
                }

                oPara1.Range.Font.Bold            = 1;
                oPara1.Range.Paragraphs.Alignment = _Word.WdParagraphAlignment.wdAlignParagraphJustify;
                oPara1.Range.Font.Name            = "Times New Roman";
                oPara1.Range.Font.Size            = 14; //Размер шрифта абзаца
                oPara1.Format.SpaceAfter          = 14;
                oPara1.Range.InsertParagraphAfter();

                _Word.Table oTable;
                _Word.Range wrdRng = WordDoc.Bookmarks.get_Item(ref oEndOfDoc).Range;
                oTable = WordDoc.Tables.Add(wrdRng, 3 + wordData.Rows.Count, 10, ref oMissing, ref oMissing); // Размерность таблицы Nх10 (N - кол-во строк зависит от кол-ва строк в принимаемом аргументе, 10 столбцов)
                oTable.AutoFitBehavior(_Word.WdAutoFitBehavior.wdAutoFitFixed);                               // wdAutoFitFixed - фиксированный размер столбцов
                oTable.Rows.SetLeftIndent(-65, _Word.WdRulerStyle.wdAdjustNone);                              //Смещение таблицы влево на 75 единиц
                oTable.Range.ParagraphFormat.SpaceBefore = 6;

                oTable.Range.Bold      = 0;                                                                        //Выделение шрифта жирным
                oTable.Range.Font.Size = 10;                                                                       //Размер шрифта в таблице
                oTable.Range.ParagraphFormat.SpaceAfter = 14;
                oTable.Range.ParagraphFormat.Alignment  = _Word.WdParagraphAlignment.wdAlignParagraphCenter;       //Горизонтальное выравнивание текста по центру ячейки
                oTable.Range.Cells.VerticalAlignment    = _Word.WdCellVerticalAlignment.wdCellAlignVerticalCenter; //Вертикальное выравнивание текста в ячейке
                oTable.Borders.InsideLineStyle          = _Word.WdLineStyle.wdLineStyleSingle;                     //Отрисовка сплошных линий внутри таблицы
                oTable.Borders.OutsideLineStyle         = _Word.WdLineStyle.wdLineStyleSingle;                     //Отрисовка сплошных линий снаружи таблицы

                //Размеры столбцов в единицах
                oTable.Columns[1].Width  = 90; //102
                oTable.Columns[2].Width  = 67;
                oTable.Columns[3].Width  = 40;
                oTable.Columns[4].Width  = 40;
                oTable.Columns[5].Width  = 40;
                oTable.Columns[6].Width  = 40;
                oTable.Columns[7].Width  = 60.03f;
                oTable.Columns[8].Width  = 62.64f;
                oTable.Columns[9].Width  = 63.51f;
                oTable.Columns[10].Width = 63; //66.41f;

                oTable.Rows[2].Height = 85;    //Высота 2 строки в таблице

                oTable.Rows[1].Cells[1].Range.Text = "Территория";
                oTable.Rows[1].Cells[2].Range.Text = "Количество случаев";

                oTable.Rows[1].Cells[3].Range.Text = "Ребёнок находится на организованном отдыхе";
                oTable.Rows[2].Cells[3].Range.Text = "Самостоятельно";
                oTable.Rows[2].Cells[4].Range.Text = "По путевке Мать и дитя";

                oTable.Rows[1].Cells[5].Range.Text = "Ребёнок находится на неорганизованном отдыхе";
                oTable.Rows[2].Cells[5].Range.Text = "Самостоятельно";
                oTable.Rows[2].Cells[6].Range.Text = "С законным представителем";

                oTable.Rows[1].Cells[7].Range.Text = "Первичная медико-санитарная помощь (ПМСП)";
                oTable.Rows[1].Cells[8].Range.Text = "Первичная специализированная медико-санитарная помощь (ПСМСП)";

                oTable.Rows[1].Cells[9].Range.Text  = "Специализированная медицинская помощь (СМП)";
                oTable.Rows[1].Cells[10].Range.Text = "Направлен (переведён) в реанимацию";

                oTable.Cell(1, 1).Merge(oTable.Cell(2, 1));                                            //Объединение 1 ячейки 1 строки с 1 ячейкой 2 строки
                oTable.Cell(1, 2).Merge(oTable.Cell(2, 2));                                            //Объединение 2 ячейки 1 строки со 2 ячейкой 2 строки
                oTable.Cell(1, 3).Merge(oTable.Cell(1, 4));                                            //Объединение 3 ячейки 1 строки с 4 ячейкой 1 строки
                oTable.Cell(1, 4).Merge(oTable.Cell(1, 5));                                            //Объединение 4 ячейки 1 строки с 5 ячейкой 1 строки
                oTable.Cell(1, 5).Merge(oTable.Cell(2, 7));                                            //Объединение 5 ячейки 1 строки с 7 ячейкой 2 строки
                oTable.Cell(1, 6).Merge(oTable.Cell(2, 8));                                            //Объединение 6 ячейки 1 строки с 8 ячейкой 2 строки
                oTable.Cell(1, 7).Merge(oTable.Cell(2, 9));                                            //Объединение 7 ячейки 1 строки с 9 ячейкой 2 строки
                oTable.Cell(1, 8).Merge(oTable.Cell(2, 10));                                           //Объединение 8 ячейки 1 строки с 10 ячейкой 2 строки

                oTable.Cell(2, 3).Range.Orientation = _Word.WdTextOrientation.wdTextOrientationUpward; //Направление текста вверх на 90 градусов
                oTable.Cell(2, 4).Range.Orientation = _Word.WdTextOrientation.wdTextOrientationUpward; //Направление текста вверх на 90 градусов

                oTable.Cell(2, 5).Range.Orientation = _Word.WdTextOrientation.wdTextOrientationUpward; //Направление текста вверх на 90 градусов
                oTable.Cell(2, 6).Range.Orientation = _Word.WdTextOrientation.wdTextOrientationUpward; //Направление текста вверх на 90 градусов

                for (int i = 0; i < wordData.Rows.Count; i++)
                {
                    for (int j = 0; j < 10; j++)
                    {
                        oTable.Cell(i + 3, j + 1).Range.Text = wordData.Rows[i][j].ToString();
                    }
                }

                oTable.Cell(3 + wordData.Rows.Count, 1).Range.Bold = 1;
                oTable.Cell(3 + wordData.Rows.Count, 1).Range.Text = "Итого";

                for (int j = 2; j <= 10; j++)
                {
                    int sumColumn = 0;

                    for (int i = 3; i < oTable.Rows.Count; i++)
                    {
                        string _char = oTable.Cell(i, j).Range.Text.ToString();
                        _char      = _char.Remove(_char.Length - 2, 2);
                        sumColumn += int.Parse(_char);
                    }

                    oTable.Cell(3 + wordData.Rows.Count, j).Range.Bold = 1;
                    oTable.Cell(3 + wordData.Rows.Count, j).Range.Text = sumColumn.ToString();
                }

                _Word.Paragraph oPara3;
                oPara3 = WordDoc.Content.Paragraphs.Add(ref oMissing);

                oPara3.Range.Font.Bold            = 0;
                oPara3.Range.Paragraphs.Alignment = _Word.WdParagraphAlignment.wdAlignParagraphJustify;
                oPara3.Range.Font.Name            = "Times New Roman";
                oPara3.Range.Font.Size            = 14; //Размер шрифта абзаца
                oPara3.Format.SpaceAfter          = 14;
                string itog = oTable.Cell(oTable.Rows.Count, 2).Range.Text.ToString();
                itog = itog.Remove(itog.Length - 2, 2);
                if (PeriodDateFrom.ToString("MMMMyyyy") == PeriodDateTo.ToString("MMMMyyyy"))
                {
                    oPara3.Range.Text = $"За {PeriodDateTo:MMMM yyyy} за медицинской помощью обратились {itog} детей, из них:";
                }
                else if (PeriodDateFrom.ToString("yyyy") == PeriodDateTo.ToString("yyyy"))
                {
                    oPara3.Range.Text = $"За {PeriodDateFrom:MMMM}-{PeriodDateTo:MMMM yyyy} за медицинской помощью обратились {itog} детей, из них:";
                }
                else
                {
                    oPara3.Range.Text = $"За {PeriodDateFrom:MMMM yyyy}-{PeriodDateTo:MMMM yyyy} за медицинской помощью обратились {itog} детей, из них:";
                }
                oPara3.Range.InsertParagraphAfter();

                string area  = "";
                string relax = "";
                string doo   = "";
                string help  = "";
                string diag  = "";

                //Создание многоуровнего списка(в данном случае создается 5 уровней)
                _Word.ListTemplate template = WordApp.ListGalleries[_Word.WdListGalleryType.wdOutlineNumberGallery].ListTemplates.get_Item(1);

                //1-й уровень
                _Word.ListLevel level = template.ListLevels[1];

                level.NumberFormat             = "%1.";
                level.TrailingCharacter        = _Word.WdTrailingCharacter.wdTrailingTab;
                level.NumberStyle              = _Word.WdListNumberStyle.wdListNumberStyleArabic;
                level.NumberPosition           = WordApp.CentimetersToPoints(0f);
                level.Alignment                = _Word.WdListLevelAlignment.wdListLevelAlignLeft;
                level.TextPosition             = WordApp.CentimetersToPoints(0.63f);
                level.TabPosition              = (float)_Word.WdConstants.wdUndefined;
                level.ResetOnHigher            = 0;
                level.StartAt                  = 1;
                level.Font.Bold                = 0;
                level.Font.Italic              = (int)_Word.WdConstants.wdUndefined;
                level.Font.StrikeThrough       = (int)_Word.WdConstants.wdUndefined;
                level.Font.Subscript           = (int)_Word.WdConstants.wdUndefined;
                level.Font.Superscript         = (int)_Word.WdConstants.wdUndefined;
                level.Font.Shadow              = (int)_Word.WdConstants.wdUndefined;
                level.Font.Outline             = (int)_Word.WdConstants.wdUndefined;
                level.Font.Emboss              = (int)_Word.WdConstants.wdUndefined;
                level.Font.Engrave             = (int)_Word.WdConstants.wdUndefined;
                level.Font.AllCaps             = (int)_Word.WdConstants.wdUndefined;
                level.Font.Hidden              = (int)_Word.WdConstants.wdUndefined;
                level.Font.Underline           = _Word.WdUnderline.wdUnderlineNone;
                level.Font.Color               = _Word.WdColor.wdColorAutomatic;
                level.Font.Size                = (int)_Word.WdConstants.wdUndefined;
                level.Font.Animation           = _Word.WdAnimation.wdAnimationNone;
                level.Font.DoubleStrikeThrough = (int)_Word.WdConstants.wdUndefined;
                level.LinkedStyle              = "";

                //2-й уровень
                level = template.ListLevels[2];

                level.NumberFormat             = "%1.%2.";
                level.TrailingCharacter        = _Word.WdTrailingCharacter.wdTrailingTab;
                level.NumberStyle              = _Word.WdListNumberStyle.wdListNumberStyleArabic;
                level.NumberPosition           = WordApp.CentimetersToPoints(0.63f);
                level.Alignment                = _Word.WdListLevelAlignment.wdListLevelAlignLeft;
                level.TextPosition             = WordApp.CentimetersToPoints(1.4f);
                level.TabPosition              = (float)_Word.WdConstants.wdUndefined;
                level.ResetOnHigher            = 1;
                level.StartAt                  = 1;
                level.Font.Bold                = 0;
                level.Font.Italic              = (int)_Word.WdConstants.wdUndefined;
                level.Font.StrikeThrough       = (int)_Word.WdConstants.wdUndefined;
                level.Font.Subscript           = (int)_Word.WdConstants.wdUndefined;
                level.Font.Superscript         = (int)_Word.WdConstants.wdUndefined;
                level.Font.Shadow              = (int)_Word.WdConstants.wdUndefined;
                level.Font.Outline             = (int)_Word.WdConstants.wdUndefined;
                level.Font.Emboss              = (int)_Word.WdConstants.wdUndefined;
                level.Font.Engrave             = (int)_Word.WdConstants.wdUndefined;
                level.Font.AllCaps             = (int)_Word.WdConstants.wdUndefined;
                level.Font.Hidden              = (int)_Word.WdConstants.wdUndefined;
                level.Font.Underline           = _Word.WdUnderline.wdUnderlineNone;
                level.Font.Color               = _Word.WdColor.wdColorAutomatic;
                level.Font.Size                = (int)_Word.WdConstants.wdUndefined;
                level.Font.Animation           = _Word.WdAnimation.wdAnimationNone;
                level.Font.DoubleStrikeThrough = (int)_Word.WdConstants.wdUndefined;
                level.LinkedStyle              = "";

                //3-й уровень
                level = template.ListLevels[3];

                level.NumberFormat             = "%1.%2.%3.";
                level.TrailingCharacter        = _Word.WdTrailingCharacter.wdTrailingTab;
                level.NumberStyle              = _Word.WdListNumberStyle.wdListNumberStyleArabic;
                level.NumberPosition           = WordApp.CentimetersToPoints(1.27f);
                level.Alignment                = _Word.WdListLevelAlignment.wdListLevelAlignLeft;
                level.TextPosition             = WordApp.CentimetersToPoints(2.16f);
                level.TabPosition              = (float)_Word.WdConstants.wdUndefined;
                level.ResetOnHigher            = 2;
                level.StartAt                  = 1;
                level.Font.Bold                = 0;
                level.Font.Italic              = (int)_Word.WdConstants.wdUndefined;
                level.Font.StrikeThrough       = (int)_Word.WdConstants.wdUndefined;
                level.Font.Subscript           = (int)_Word.WdConstants.wdUndefined;
                level.Font.Superscript         = (int)_Word.WdConstants.wdUndefined;
                level.Font.Shadow              = (int)_Word.WdConstants.wdUndefined;
                level.Font.Outline             = (int)_Word.WdConstants.wdUndefined;
                level.Font.Emboss              = (int)_Word.WdConstants.wdUndefined;
                level.Font.Engrave             = (int)_Word.WdConstants.wdUndefined;
                level.Font.AllCaps             = (int)_Word.WdConstants.wdUndefined;
                level.Font.Hidden              = (int)_Word.WdConstants.wdUndefined;
                level.Font.Underline           = _Word.WdUnderline.wdUnderlineNone;
                level.Font.Color               = _Word.WdColor.wdColorAutomatic;
                level.Font.Size                = (int)_Word.WdConstants.wdUndefined;
                level.Font.Animation           = _Word.WdAnimation.wdAnimationNone;
                level.Font.DoubleStrikeThrough = (int)_Word.WdConstants.wdUndefined;
                level.LinkedStyle              = "";

                //4-й уровень
                level = template.ListLevels[4];

                level.NumberFormat             = "%1.%2.%3.%4.";
                level.TrailingCharacter        = _Word.WdTrailingCharacter.wdTrailingTab;
                level.NumberStyle              = _Word.WdListNumberStyle.wdListNumberStyleArabic;
                level.NumberPosition           = WordApp.CentimetersToPoints(1.9f);
                level.Alignment                = _Word.WdListLevelAlignment.wdListLevelAlignLeft;
                level.TextPosition             = WordApp.CentimetersToPoints(3.05f);
                level.TabPosition              = (float)_Word.WdConstants.wdUndefined;
                level.ResetOnHigher            = 3;
                level.StartAt                  = 1;
                level.Font.Bold                = 0;
                level.Font.Italic              = (int)_Word.WdConstants.wdUndefined;
                level.Font.StrikeThrough       = (int)_Word.WdConstants.wdUndefined;
                level.Font.Subscript           = (int)_Word.WdConstants.wdUndefined;
                level.Font.Superscript         = (int)_Word.WdConstants.wdUndefined;
                level.Font.Shadow              = (int)_Word.WdConstants.wdUndefined;
                level.Font.Outline             = (int)_Word.WdConstants.wdUndefined;
                level.Font.Emboss              = (int)_Word.WdConstants.wdUndefined;
                level.Font.Engrave             = (int)_Word.WdConstants.wdUndefined;
                level.Font.AllCaps             = (int)_Word.WdConstants.wdUndefined;
                level.Font.Hidden              = (int)_Word.WdConstants.wdUndefined;
                level.Font.Underline           = _Word.WdUnderline.wdUnderlineNone;
                level.Font.Color               = _Word.WdColor.wdColorAutomatic;
                level.Font.Size                = (int)_Word.WdConstants.wdUndefined;
                level.Font.Animation           = _Word.WdAnimation.wdAnimationNone;
                level.Font.DoubleStrikeThrough = (int)_Word.WdConstants.wdUndefined;
                level.LinkedStyle              = "";

                //5-й уровень
                level = template.ListLevels[5];

                level.NumberFormat             = "%1.%2.%3.%4.%5.";
                level.TrailingCharacter        = _Word.WdTrailingCharacter.wdTrailingTab;
                level.NumberStyle              = _Word.WdListNumberStyle.wdListNumberStyleArabic;
                level.NumberPosition           = WordApp.CentimetersToPoints(2.54f);
                level.Alignment                = _Word.WdListLevelAlignment.wdListLevelAlignLeft;
                level.TextPosition             = WordApp.CentimetersToPoints(3.94f);
                level.TabPosition              = (float)_Word.WdConstants.wdUndefined;
                level.ResetOnHigher            = 4;
                level.StartAt                  = 1;
                level.Font.Bold                = 0;
                level.Font.Italic              = (int)_Word.WdConstants.wdUndefined;
                level.Font.StrikeThrough       = (int)_Word.WdConstants.wdUndefined;
                level.Font.Subscript           = (int)_Word.WdConstants.wdUndefined;
                level.Font.Superscript         = (int)_Word.WdConstants.wdUndefined;
                level.Font.Shadow              = (int)_Word.WdConstants.wdUndefined;
                level.Font.Outline             = (int)_Word.WdConstants.wdUndefined;
                level.Font.Emboss              = (int)_Word.WdConstants.wdUndefined;
                level.Font.Engrave             = (int)_Word.WdConstants.wdUndefined;
                level.Font.AllCaps             = (int)_Word.WdConstants.wdUndefined;
                level.Font.Hidden              = (int)_Word.WdConstants.wdUndefined;
                level.Font.Underline           = _Word.WdUnderline.wdUnderlineNone;
                level.Font.Color               = _Word.WdColor.wdColorAutomatic;
                level.Font.Size                = (int)_Word.WdConstants.wdUndefined;
                level.Font.Animation           = _Word.WdAnimation.wdAnimationNone;
                level.Font.DoubleStrikeThrough = (int)_Word.WdConstants.wdUndefined;
                level.LinkedStyle              = "";

                template.Name = "";

                for (int i = 0; i < textData.Rows.Count; i++)
                {
                    for (int j = 0; j < 10; j++)
                    {
                        switch (j)
                        {
                        case 0:
                            if (area != textData.Rows[i][j].ToString())
                            {
                                area  = textData.Rows[i][j].ToString();
                                relax = "";

                                j++;

                                _Word.Paragraph oPara4;
                                oPara4 = WordDoc.Content.Paragraphs.Add(ref oMissing);

                                oPara4.Range.Font.Bold            = 0;
                                oPara4.Range.Font.Underline       = _Word.WdUnderline.wdUnderlineSingle;
                                oPara4.Range.Paragraphs.Alignment = _Word.WdParagraphAlignment.wdAlignParagraphJustify;
                                oPara4.Range.Font.Name            = "Times New Roman";
                                oPara4.Range.Font.Size            = 14; //Размер шрифта абзаца
                                oPara4.Range.Text = $"{area} ({textData.Rows[i][j]}):";

                                oPara4.Range.ListFormat.ApplyListTemplateWithLevel(template, false, _Word.WdListApplyTo.wdListApplyToWholeList, _Word.WdDefaultListBehavior.wdWord10ListBehavior);
                                oPara4.Range.SetListLevel(1);
                                oPara4.Range.InsertParagraphAfter();
                            }
                            break;

                        case 2:
                            if (relax != textData.Rows[i][j].ToString())
                            {
                                relax = textData.Rows[i][j].ToString();
                                doo   = "";

                                j++;

                                _Word.Paragraph oPara4;
                                oPara4 = WordDoc.Content.Paragraphs.Add(ref oMissing);

                                oPara4.Range.Font.Bold            = 0;
                                oPara4.Range.Font.Underline       = _Word.WdUnderline.wdUnderlineNone;
                                oPara4.Range.Paragraphs.Alignment = _Word.WdParagraphAlignment.wdAlignParagraphJustify;
                                oPara4.Range.Font.Name            = "Times New Roman";
                                oPara4.Range.Font.Size            = 14; //Размер шрифта абзаца
                                oPara4.Range.Text = $"{relax} ({textData.Rows[i][j]}):";
                                oPara4.Range.ListFormat.ApplyListTemplateWithLevel(template, false, _Word.WdListApplyTo.wdListApplyToWholeList, _Word.WdDefaultListBehavior.wdWord10ListBehavior);
                                oPara4.Range.SetListLevel(2);
                                oPara4.Range.InsertParagraphAfter();
                            }
                            break;

                        case 4:
                            if (doo != textData.Rows[i][j].ToString())
                            {
                                doo  = textData.Rows[i][j].ToString();
                                help = "";

                                j++;

                                _Word.Paragraph oPara4;
                                oPara4 = WordDoc.Content.Paragraphs.Add(ref oMissing);

                                oPara4.Range.Font.Bold            = 0;
                                oPara4.Range.Font.Underline       = _Word.WdUnderline.wdUnderlineNone;
                                oPara4.Range.Paragraphs.Alignment = _Word.WdParagraphAlignment.wdAlignParagraphJustify;
                                oPara4.Range.Font.Name            = "Times New Roman";
                                oPara4.Range.Font.Size            = 14; //Размер шрифта абзаца
                                oPara4.Range.Text = $"{doo} ({textData.Rows[i][j]}):";
                                oPara4.Range.ListFormat.ApplyListTemplateWithLevel(template, false, _Word.WdListApplyTo.wdListApplyToWholeList, _Word.WdDefaultListBehavior.wdWord10ListBehavior);
                                oPara4.Range.SetListLevel(3);
                                oPara4.Range.InsertParagraphAfter();
                            }
                            break;

                        case 6:
                            if (help != textData.Rows[i][j].ToString())
                            {
                                help = textData.Rows[i][j].ToString();
                                diag = "";

                                j++;

                                _Word.Paragraph oPara4;
                                oPara4 = WordDoc.Content.Paragraphs.Add(ref oMissing);

                                oPara4.Range.Font.Bold            = 0;
                                oPara4.Range.Font.Underline       = _Word.WdUnderline.wdUnderlineNone;
                                oPara4.Range.Paragraphs.Alignment = _Word.WdParagraphAlignment.wdAlignParagraphJustify;
                                oPara4.Range.Font.Name            = "Times New Roman";
                                oPara4.Range.Font.Size            = 14; //Размер шрифта абзаца
                                oPara4.Range.Text = $"{help} ({textData.Rows[i][j]}):";
                                oPara4.Range.ListFormat.ApplyListTemplateWithLevel(template, false, _Word.WdListApplyTo.wdListApplyToWholeList, _Word.WdDefaultListBehavior.wdWord10ListBehavior);
                                oPara4.Range.SetListLevel(4);
                                oPara4.Range.InsertParagraphAfter();
                            }
                            break;

                        case 8:
                            if (diag != textData.Rows[i][j].ToString())
                            {
                                diag = textData.Rows[i][j].ToString();

                                j++;

                                _Word.Paragraph oPara4;
                                oPara4 = WordDoc.Content.Paragraphs.Add();

                                oPara4.Range.Font.Bold            = 0;
                                oPara4.Range.Font.Underline       = _Word.WdUnderline.wdUnderlineNone;
                                oPara4.Range.Paragraphs.Alignment = _Word.WdParagraphAlignment.wdAlignParagraphJustify;
                                oPara4.Range.Font.Name            = "Times New Roman";
                                oPara4.Range.Font.Size            = 14; //Размер шрифта абзаца
                                oPara4.Range.Text = $"{diag} - {textData.Rows[i][j]}";
                                oPara4.Range.ListFormat.ApplyListTemplateWithLevel(template, false, _Word.WdListApplyTo.wdListApplyToWholeList, _Word.WdDefaultListBehavior.wdWord10ListBehavior);
                                oPara4.Range.SetListLevel(5);
                                oPara4.Range.InsertParagraphAfter();
                            }
                            break;
                        }
                    }
                }
                //WordDoc.Paragraphs[WordDoc.Paragraphs.Count].Range.Delete(); //Удаление последнего пустого абзаца
                WordDoc.Paragraphs[WordDoc.Paragraphs.Count].Format.Reset();

                _Word.Paragraph oPara5 = WordDoc.Content.Paragraphs.Add();

                /*_Word.Range wrdRng_1 = oPara5.Range;
                *  _Word.Table oTable_1 = WordDoc.Tables.Add(wrdRng_1, 2, 2, ref oMissing, ref oMissing);
                *
                *  var table = WordDoc.Tables[WordDoc.Tables.Count];
                *  table.set_Style("Сетка таблицы");
                *  table.ApplyStyleHeadingRows = true;
                *  table.ApplyStyleLastRow = false;
                *  table.ApplyStyleFirstColumn = true;
                *  table.ApplyStyleLastColumn = false;
                *  table.ApplyStyleRowBands = true;
                *  table.ApplyStyleColumnBands = false;*/

                _Word.Table oTable_1;
                _Word.Range wrdRng_1 = WordDoc.Bookmarks.get_Item(ref oEndOfDoc).Range;
                oTable_1 = WordDoc.Tables.Add(wrdRng_1, 2 + classTable.Rows.Count, 14, ref oMissing, ref oMissing); // Размерность таблицы Nх10 (N - кол-во строк зависит от кол-ва строк в принимаемом аргументе, 10 столбцов)
                oTable_1.AutoFitBehavior(_Word.WdAutoFitBehavior.wdAutoFitFixed);                                   // wdAutoFitFixed - фиксированный размер столбцов
                oTable_1.Rows.SetLeftIndent(-55, _Word.WdRulerStyle.wdAdjustNone);                                  //Смещение таблицы влево на 75 единиц
                oTable_1.Range.ParagraphFormat.SpaceBefore = 6;

                oTable_1.Range.Bold      = 0;                                                                        //Выделение шрифта жирным
                oTable_1.Range.Font.Size = 10;                                                                       //Размер шрифта в таблице
                oTable_1.Range.ParagraphFormat.SpaceAfter = 14;
                oTable_1.Range.ParagraphFormat.Alignment  = _Word.WdParagraphAlignment.wdAlignParagraphCenter;       //Горизонтальное выравнивание текста по центру ячейки
                oTable_1.Range.Cells.VerticalAlignment    = _Word.WdCellVerticalAlignment.wdCellAlignVerticalCenter; //Вертикальное выравнивание текста в ячейке
                oTable_1.Borders.InsideLineStyle          = _Word.WdLineStyle.wdLineStyleSingle;                     //Отрисовка сплошных линий внутри таблицы
                oTable_1.Borders.OutsideLineStyle         = _Word.WdLineStyle.wdLineStyleSingle;                     //Отрисовка сплошных линий снаружи таблицы

                //Размеры столбцов в единицах
                oTable_1.Columns[1].Width  = 90; //102
                oTable_1.Columns[2].Width  = 35;
                oTable_1.Columns[3].Width  = 35;
                oTable_1.Columns[4].Width  = 35;
                oTable_1.Columns[5].Width  = 35;
                oTable_1.Columns[6].Width  = 35;
                oTable_1.Columns[7].Width  = 35;
                oTable_1.Columns[8].Width  = 35;
                oTable_1.Columns[9].Width  = 35;
                oTable_1.Columns[10].Width = 35;
                oTable_1.Columns[11].Width = 35;
                oTable_1.Columns[12].Width = 35;
                oTable_1.Columns[13].Width = 35;
                oTable_1.Columns[14].Width = 35;

                oTable_1.Rows[1].Height = 95; //Высота 1 строки в таблице

                oTable_1.Rows[1].Cells[1].Range.Text = "Территория";
                oTable_1.Rows[1].Cells[2].Range.Text = "Травмы";

                oTable_1.Rows[1].Cells[3].Range.Text = "Утопления";
                oTable_1.Rows[1].Cells[4].Range.Text = "Инфекционные";
                oTable_1.Rows[1].Cells[5].Range.Text = "Хирургические";

                oTable_1.Rows[1].Cells[6].Range.Text = "Соматические";
                oTable_1.Rows[1].Cells[7].Range.Text = "Нейрохирургические";
                oTable_1.Rows[1].Cells[8].Range.Text = "Неврологические";

                oTable_1.Rows[1].Cells[9].Range.Text  = "ЛОР";
                oTable_1.Rows[1].Cells[10].Range.Text = "Отравления";

                oTable_1.Rows[1].Cells[11].Range.Text = "Алкогольные отравления";
                oTable_1.Rows[1].Cells[12].Range.Text = "Наркотические отравления";
                oTable_1.Rows[1].Cells[13].Range.Text = "Прочие";
                oTable_1.Rows[1].Cells[14].Range.Bold = 1;
                oTable_1.Rows[1].Cells[14].Range.Text = "Всего";

                /*oTable_1.Cell(1, 1).Merge(oTable.Cell(2, 1)); //Объединение 1 ячейки 1 строки с 1 ячейкой 2 строки
                 * oTable_1.Cell(1, 2).Merge(oTable.Cell(2, 2)); //Объединение 2 ячейки 1 строки со 2 ячейкой 2 строки
                 * oTable_1.Cell(1, 3).Merge(oTable.Cell(1, 4)); //Объединение 3 ячейки 1 строки с 4 ячейкой 1 строки
                 * oTable_1.Cell(1, 4).Merge(oTable.Cell(1, 5)); //Объединение 4 ячейки 1 строки с 5 ячейкой 1 строки
                 * oTable_1.Cell(1, 5).Merge(oTable.Cell(2, 7)); //Объединение 5 ячейки 1 строки с 7 ячейкой 2 строки
                 * oTable_1.Cell(1, 6).Merge(oTable.Cell(2, 8)); //Объединение 6 ячейки 1 строки с 8 ячейкой 2 строки
                 * oTable_1.Cell(1, 7).Merge(oTable.Cell(2, 9)); //Объединение 7 ячейки 1 строки с 9 ячейкой 2 строки
                 * oTable_1.Cell(1, 8).Merge(oTable.Cell(2, 10)); //Объединение 8 ячейки 1 строки с 10 ячейкой 2 строки*/

                for (int i = 2; i <= 14; i++)
                {
                    oTable_1.Cell(1, i).Range.Orientation = _Word.WdTextOrientation.wdTextOrientationUpward; //Направление текста вверх на 90 градусов
                }

                //oTable_1.Cell(1, 3).Range.Orientation = _Word.WdTextOrientation.wdTextOrientationUpward; //Направление текста вверх на 90 градусов
                //oTable_1.Cell(2, 5).Range.Orientation = _Word.WdTextOrientation.wdTextOrientationUpward; //Направление текста вверх на 90 градусов
                //oTable_1.Cell(2, 6).Range.Orientation = _Word.WdTextOrientation.wdTextOrientationUpward; //Направление текста вверх на 90 градусов

                for (int i = 0; i < classTable.Rows.Count; i++)
                {
                    for (int j = 0; j <= 12; j++)
                    {
                        oTable_1.Cell(i + 2, j + 1).Range.Text = classTable.Rows[i][j].ToString();
                    }
                }

                for (int i = 2; i < oTable_1.Rows.Count; i++)
                {
                    int sumColumn = 0;

                    for (int j = 2; j <= 13; j++)
                    {
                        string _char = oTable_1.Cell(i, j).Range.Text.ToString();
                        _char      = _char.Remove(_char.Length - 2, 2);
                        sumColumn += int.Parse(_char);
                    }

                    oTable_1.Cell(i, 14).Range.Bold = 1;
                    oTable_1.Cell(i, 14).Range.Text = sumColumn.ToString();
                }

                oTable_1.Cell(2 + classTable.Rows.Count, 1).Range.Bold = 1;
                oTable_1.Cell(2 + classTable.Rows.Count, 1).Range.Text = "Итого";

                for (int j = 2; j <= 14; j++)
                {
                    int sumColumn = 0;

                    for (int i = 2; i < oTable_1.Rows.Count; i++)
                    {
                        string _char = oTable_1.Cell(i, j).Range.Text.ToString();
                        _char      = _char.Remove(_char.Length - 2, 2);
                        sumColumn += int.Parse(_char);
                    }

                    oTable_1.Cell(2 + wordData.Rows.Count, j).Range.Bold = 1;
                    oTable_1.Cell(2 + wordData.Rows.Count, j).Range.Text = sumColumn.ToString();
                }

                _Word.Paragraph oPara6;
                oPara6 = WordDoc.Content.Paragraphs.Add(ref oMissing);
                oPara6.Range.Font.Bold            = 0;
                oPara6.Range.Paragraphs.Alignment = _Word.WdParagraphAlignment.wdAlignParagraphJustify;
                oPara6.Range.Font.Name            = "Times New Roman";
                oPara6.Range.Font.Size            = 14; //Размер шрифта абзаца
                oPara6.Format.SpaceAfter          = 14;

                string itog_1 = oTable_1.Cell(oTable_1.Rows.Count, 14).Range.Text.ToString();
                itog_1 = itog_1.Remove(itog_1.Length - 2, 2);

                string itog_list = "";

                for (int i = 2; i <= 13; i++)
                {
                    string sum = oTable_1.Cell(oTable_1.Rows.Count, i).Range.Text;
                    sum = sum.Remove(sum.Length - 2, 2);
                    string chld = "";

                    if (int.Parse(sum) > 0)
                    {
                        switch (int.Parse(sum.Substring(sum.Length - 1)))
                        {
                        case 1:
                            chld = "ребенок";
                            break;

                        case 2:
                        case 3:
                        case 4:
                            chld = "ребенка";
                            break;

                        default:
                            chld = "детей";
                            break;
                        }
                    }

                    if (i == 2)
                    {
                        if (int.Parse(sum) > 0)
                        {
                            itog_list = $"- {oTable_1.Cell(1, i).Range.Text.Remove(oTable_1.Cell(1, i).Range.Text.Length - 2, 2)} - {sum} {chld} ({Math.Round((double.Parse(sum) * 100) / double.Parse(itog_1),1)}%); \r\n";
                        }
                    }
                    else
                    {
                        if (int.Parse(sum) > 0)
                        {
                            itog_list += $"- {oTable_1.Cell(1, i).Range.Text.Remove(oTable_1.Cell(1, i).Range.Text.Length - 2, 2)} - {sum} {chld} ({Math.Round((double.Parse(sum) * 100) / double.Parse(itog_1), 1)}%); \r\n";
                        }
                    }
                }

                string all_chld = "";
                if (int.Parse(itog_1) > 0)
                {
                    switch (int.Parse(itog_1.Substring(itog_1.Length - 1)))
                    {
                    case 1:
                        all_chld = "ребенок";
                        break;

                    case 2:
                    case 3:
                    case 4:
                        all_chld = "ребенка";
                        break;

                    default:
                        all_chld = "детей";
                        break;
                    }
                }

                if (PeriodDateFrom.ToString("MMMMyyyy") == PeriodDateTo.ToString("MMMMyyyy"))
                {
                    oPara6.Range.Text = $"За {PeriodDateTo:MMMM yyyy} года включительно из детских оздоровительных организаций всех форм собственности в медицинские организации края обратилось(ись) {itog_1} {all_chld}, в том числе:\r\n{itog_list}";
                }
                else if (PeriodDateFrom.ToString("yyyy") == PeriodDateTo.ToString("yyyy"))
                {
                    oPara6.Range.Text = $"За {PeriodDateFrom:MMMM}-{PeriodDateTo:MMMM yyyy} года включительно из детских оздоровительных организаций всех форм собственности в медицинские организации края обратилось(ись) {itog_1} {all_chld}, в том числе:\r\n{itog_list}";
                }
                else
                {
                    oPara6.Range.Text = $"За {PeriodDateFrom:MMMM yyyy}-{PeriodDateTo:MMMM yyyy} года включительно из детских оздоровительных организаций всех форм собственности в медицинские организации края обратилось(ись) {itog_1} {all_chld}, в том числе:\r\n{itog_list}";
                }
                oPara6.Range.InsertParagraphAfter();


                string report_chld_org    = "";
                string report_chld_nonorg = "";

                for (int i = 0; i < CHLDReport.Rows.Count; i++)
                {
                    string str = CHLDReport.Rows[i][1].ToString();
                    switch (CHLDReport.Rows[i][0].ToString())
                    {
                    case "Организованный отдых":
                        switch (int.Parse(str.Substring(str.Length - 1)))
                        {
                        case 1:
                            report_chld_org = "ребенку";
                            break;

                        default:
                            report_chld_org = "детям";
                            break;
                        }
                        break;

                    case "Неорганизованный отдых":
                        switch (int.Parse(str.Substring(str.Length - 1)))
                        {
                        case 1:
                            report_chld_nonorg = "ребенку";
                            break;

                        default:
                            report_chld_nonorg = "детям";
                            break;
                        }
                        break;
                    }
                }

                if (CHLDReport.Rows.Count > 1)
                {
                    _Word.Paragraph oPara7;
                    oPara7 = WordDoc.Content.Paragraphs.Add(ref oMissing);
                    oPara7.Range.Font.Bold            = 0;
                    oPara7.Range.Paragraphs.Alignment = _Word.WdParagraphAlignment.wdAlignParagraphJustify;
                    oPara7.Range.Font.Name            = "Times New Roman";
                    oPara7.Range.Font.Size            = 14; //Размер шрифта абзаца
                    oPara7.Format.SpaceAfter          = 14;
                    oPara7.Range.Text = $"{CHLDReport.Rows[0][0]} - специализированная медицинская помощь оказана {CHLDReport.Rows[0][1]} {report_chld_org}.";
                    oPara7.Range.InsertParagraphAfter();

                    _Word.Paragraph oPara8;
                    oPara8 = WordDoc.Content.Paragraphs.Add(ref oMissing);
                    oPara8.Range.Font.Bold            = 0;
                    oPara8.Range.Paragraphs.Alignment = _Word.WdParagraphAlignment.wdAlignParagraphJustify;
                    oPara8.Range.Font.Name            = "Times New Roman";
                    oPara8.Range.Font.Size            = 14; //Размер шрифта абзаца
                    oPara8.Format.SpaceAfter          = 14;
                    oPara8.Range.Text = $"{CHLDReport.Rows[1][0]} - специализированная медицинская помощь оказана {CHLDReport.Rows[1][1]} {report_chld_nonorg}.";
                    oPara8.Range.InsertParagraphAfter();
                }
                else if (CHLDReport.Rows.Count == 1)
                {
                    _Word.Paragraph oPara7;
                    oPara7 = WordDoc.Content.Paragraphs.Add(ref oMissing);
                    oPara7.Range.Font.Bold            = 0;
                    oPara7.Range.Paragraphs.Alignment = _Word.WdParagraphAlignment.wdAlignParagraphJustify;
                    oPara7.Range.Font.Name            = "Times New Roman";
                    oPara7.Range.Font.Size            = 14; //Размер шрифта абзаца
                    oPara7.Format.SpaceAfter          = 14;
                    oPara7.Range.Text = $"{CHLDReport.Rows[0][0]} - специализированная медицинская помощь оказана {CHLDReport.Rows[0][1]} {report_chld_org}.";
                    oPara7.Range.InsertParagraphAfter();
                }

                // WordDoc.Paragraphs[WordDoc.Paragraphs.Count].Range.Delete(); //Удаление последнего пустого абзаца
                WordApp.Visible = true;
            }
            catch (Exception ex)
            {
                logger.Error(ex, $"\r\n#---------#\r\n{ex.StackTrace}\r\n##---------##\r\n{ex.Message}\r\n###---------###\r\n{ex.Source}");
                MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 15
0
        public static void exportCustomers(List <Customer> customers)
        {
            Word.Application wordApp = new Word.Application();
            wordApp.ShowAnimation = false;
            wordApp.Visible       = false;
            object missingValue = System.Reflection.Missing.Value;

            Word.Document document = wordApp.Documents.Add(ref missingValue, ref missingValue, ref missingValue, ref missingValue);

            foreach (Word.Section section in document.Sections)
            {
                Word.Range headerRange = section.Headers[Word.WdHeaderFooterIndex.wdHeaderFooterPrimary].Range;
                headerRange.Fields.Add(headerRange, Word.WdFieldType.wdFieldPage);
                headerRange.ParagraphFormat.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;
                headerRange.Font.ColorIndex           = Word.WdColorIndex.wdBlue;
                headerRange.Font.Size = 12;
                headerRange.Text      = "List of customers";
            }

            foreach (Word.Section section in document.Sections)
            {
                Word.Range footerRange = section.Footers[Word.WdHeaderFooterIndex.wdHeaderFooterPrimary].Range;
                footerRange.Font.ColorIndex           = Word.WdColorIndex.wdDarkRed;
                footerRange.Font.Size                 = 12;
                footerRange.ParagraphFormat.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;
                footerRange.Text = "Programming Engineering";
            }

            document.Content.SetRange(0, 0);
            foreach (Customer customer in customers)
            {
                document.Content.Text = "Customer informations" + Environment.NewLine;
                Word.Paragraph firstNameParagraph = document.Content.Paragraphs.Add(ref missingValue);
                object         styleHeading       = "Heading 2";
                firstNameParagraph.Range.set_Style(ref styleHeading);
                firstNameParagraph.Range.Text = "First Name: " + customer.FirstName;
                firstNameParagraph.Range.InsertParagraphAfter();

                Word.Paragraph lastNameParagraph = document.Content.Paragraphs.Add(ref missingValue);
                lastNameParagraph.Range.set_Style(ref styleHeading);
                lastNameParagraph.Range.Text = "Last Name: " + customer.LastName;
                lastNameParagraph.Range.InsertParagraphAfter();

                Word.Paragraph cnpParagraph = document.Content.Paragraphs.Add(ref missingValue);
                cnpParagraph.Range.set_Style(ref styleHeading);
                cnpParagraph.Range.Text = "CNP: " + customer.Cnp;
                cnpParagraph.Range.InsertParagraphAfter();

                Word.Paragraph birthDateParagraph = document.Content.Paragraphs.Add(ref missingValue);
                birthDateParagraph.Range.set_Style(ref styleHeading);
                birthDateParagraph.Range.Text = "Birthdate: " + customer.BirthDate;
                birthDateParagraph.Range.InsertParagraphAfter();

                Word.Paragraph phoneParagraph = document.Content.Paragraphs.Add(ref missingValue);
                phoneParagraph.Range.set_Style(ref styleHeading);
                phoneParagraph.Range.Text = "Customer's phone: " + customer.Phone;
                phoneParagraph.Range.InsertParagraphAfter();

                Word.Paragraph emailParagraph = document.Content.Paragraphs.Add(ref missingValue);
                emailParagraph.Range.set_Style(ref styleHeading);
                emailParagraph.Range.Text = "Customer's email: " + customer.Email;
                emailParagraph.Range.InsertParagraphAfter();

                Word.Paragraph countryParagraph = document.Content.Paragraphs.Add(ref missingValue);
                countryParagraph.Range.set_Style(ref styleHeading);
                countryParagraph.Range.Text = "Customer's country: " + customer.Country;
                countryParagraph.Range.InsertParagraphAfter();

                Word.Paragraph countyParagraph = document.Content.Paragraphs.Add(ref missingValue);
                countyParagraph.Range.set_Style(ref styleHeading);
                countyParagraph.Range.Text = "Customer's county: " + customer.County;
                countyParagraph.Range.InsertParagraphAfter();

                Word.Paragraph cityParagraph = document.Content.Paragraphs.Add(ref missingValue);
                cityParagraph.Range.set_Style(ref styleHeading);
                cityParagraph.Range.Text = "Customer's city: " + customer.City;
                cityParagraph.Range.InsertParagraphAfter();

                Word.Paragraph localityParagraph = document.Content.Paragraphs.Add(ref missingValue);
                localityParagraph.Range.set_Style(ref styleHeading);
                localityParagraph.Range.Text = "Customer's locality: " + customer.Locality;
                localityParagraph.Range.InsertParagraphAfter();

                Word.Paragraph streetParagraph = document.Content.Paragraphs.Add(ref missingValue);
                streetParagraph.Range.set_Style(ref styleHeading);
                streetParagraph.Range.Text = "Customer's street: " + customer.Street;
                streetParagraph.Range.InsertParagraphAfter();

                Word.Paragraph streetNoParagraph = document.Content.Paragraphs.Add(ref missingValue);
                streetNoParagraph.Range.set_Style(ref styleHeading);
                streetNoParagraph.Range.Text = "Customer's street no.: " + customer.StreetNo;
                streetNoParagraph.Range.InsertParagraphAfter();
            }

            object filename = @"C:\Customers.docx";

            document.SaveAs2(ref filename);
            document.Close(ref missingValue, ref missingValue, ref missingValue);
            document = null;
            wordApp.Quit(ref missingValue, ref missingValue, ref missingValue);
            wordApp = null;
        }
Exemplo n.º 16
0
        // Callback function for Keyboard hook.
        private static IntPtr HookCallback(
            int nCode, IntPtr wParam, IntPtr lParam)
        {
            if (nCode >= 0 && wParam == (IntPtr)WM_KEYDOWN)
            {
                IntPtr active = GetForegroundWindow();
                if (!(active.Equals(self.MainWindowHandle) || active.Equals(GUIManager.GUIHandle)))
                {
                    inputStatus = KEYBOARD_IDLE;
                    GUIManager.disappear();
                }

                #region KeyCheck
                else
                {
                    currDoc = ThisAddIn.getCurrDocument();
                    int vkCode = Marshal.ReadInt32(lParam);

                    if (active.Equals(GUIManager.GUIHandle))
                    {
                        hotkeyTimer.Start();

                        int maxCount = tempList.Count - wrappedPage * REFERENCE_PER_PAGE - 1;

                        if (vkCode == KeyboardMapping.Keys["1"])
                        {
                            selectedItem = Math.Min(0, maxCount);
                        }
                        else if (vkCode == KeyboardMapping.Keys["2"])
                        {
                            selectedItem = Math.Min(1, maxCount);
                        }
                        else if (vkCode == KeyboardMapping.Keys["3"])
                        {
                            selectedItem = Math.Min(2, maxCount);
                        }
                        else if (vkCode == KeyboardMapping.Keys["4"])
                        {
                            selectedItem = Math.Min(3, maxCount);
                        }
                        else if (vkCode == KeyboardMapping.Keys["5"])
                        {
                            selectedItem = Math.Min(4, maxCount);
                        }
                        else if (vkCode == KeyboardMapping.Keys["VK_LEFT"])
                        {
                            if (wrappedPage > 0) wrappedPage -= 1;
                            selectedItem = 0;
                        }
                        else if (vkCode == KeyboardMapping.Keys["VK_RIGHT"])
                        {
                            if (wrappedPage < maxPage)
                            {
                                wrappedPage += 1;
                                selectedItem = 0;
                            }
                            else selectedItem = maxCount;
                        }

                        GUIManager.chooseItem(selectedItem, wrappedPage);
                    }

                    if (inputStatus == KEYBOARD_IDLE)
                    {
                        // Register place for starting typing.
                        inputStatus = KEYBOARD_TYPING;
                        Messenger.message("User is Typing!");
                        selStart = currDoc.Application.Selection.End;

                        //start Timer
                        resetTimer();
                    }
                    else if (inputStatus == KEYBOARD_TYPING)
                    {
                        resetTimer();
                    }
                    else if (inputStatus == KEYBOARD_PREFLISTSHOWED)
                    {
                        if (checkHotKey(vkCode, extendSentenceHotKey, 1))
                        {
                            string extending = tempList[wrappedPage * REFERENCE_PER_PAGE + selectedItem].getContent();

                            sentenceLength.Add(extending.Length);
                            int tempPos = selEnd;

                            // Print string
                            currDoc.Application.Selection.Start = selEnd;
                            currDoc.Application.Selection.End = selEnd;
                            currDoc.Application.Selection.TypeText(extending);

                            // Move cursor
                            selEnd = tempPos + extending.Length;
                            selStart = tempPos;
                            rng = currDoc.Range(selStart, selEnd);
                            rng.Select();

                            Messenger.message("Sentence Extended!");
                        }
                        else if (checkHotKey(vkCode, deleteSentenceHotKey, 4))
                        {
                            if (sentenceLength.Any())
                            {
                                int lastAdded = sentenceLength.Count - 1;
                                selStart = selEnd - sentenceLength[lastAdded];
                                rng = currDoc.Range(selStart, selEnd);
                                rng.Delete();
                                sentenceLength.RemoveAt(lastAdded);

                                if (sentenceLength.Any())
                                {
                                    lastAdded = sentenceLength.Count - 1;
                                    selEnd = selStart;
                                    selStart = selEnd - sentenceLength[lastAdded];
                                    rng = currDoc.Range(selStart, selEnd);
                                    rng.Select();
                                }
                                else
                                {
                                    selEnd = selStart;
                                    rng = currDoc.Range(selStart, selEnd);
                                    rng.Select();
                                }

                                Messenger.message("Sentence Reverted!");
                            }
                            else Messenger.message("Nothing extended yet!");
                        }
                        else if (vkCode == KeyboardMapping.Keys["SPACE"])
                        {
                            Messenger.message("KeyboardStatRestored!\n");

                            selStart = selEnd;
                            rng = currDoc.Range(selStart, selEnd);
                            rng.Select();

                            GUIManager.disappear();
                            inputStatus = KEYBOARD_TYPING;
                            sentenceLength = new List<int>();
                        }
                    }
                }
                #endregion
            }
            return CallNextHookEx(_hookID, nCode, wParam, lParam);
        }
Exemplo n.º 17
0
        private static ICharacter MapSingleCharacter(nat.Range range)
        {
            var font = new Font(range.Font.Name);

            return(new Character(range.Text, font));
        }
Exemplo n.º 18
0
 protected virtual string GetNewFont(Word.Range range) => null;
Exemplo n.º 19
0
 void Application_DocumentChange()
 {
     //Reassign values to the document and wiki page states.
     lastActiveDocument = ActiveDocumentInstance;
     lastActiveDocumentFullName = ActiveDocumentFullName;
     activeDocumentContent = ActiveDocumentContentRange;
     //if current document is a wiki page.
     if (EditedPages.ContainsKey(lastActiveDocumentFullName))
     {
         currentPageFullName = EditedPages[lastActiveDocumentFullName];
         CurrentPagePublished = false;
         if (PublishedStatus.ContainsKey(currentPageFullName))
         {
             if (PublishedStatus[currentPageFullName])
             {
                 CurrentPagePublished = true;
             }
         }
     }
     else
     {
         currentPageFullName = null;
         CurrentPagePublished = false;
     }
 }
Exemplo n.º 20
0
 /// <summary>
 /// A Patch represents a region of the original text.  It contains the different options Turkers have supplied for this particular range.
 /// </summary>
 /// <param name="range">The Range object this Patch represents</param>
 /// <param name="replacements">A list of replacement options for this range</param>
 public Patch(Word.Range range, List<string> replacements)
 {
     this.range = range;
     this.replacements = replacements;
     this.original = range.Text;
 }
Exemplo n.º 21
0
 // The Action this plugin will take after Reaction Time elapsed.
 private static void stoppedType(object source, System.Timers.ElapsedEventArgs e)
 {
     // Check whether is connected to background.
     if (Communicator.isConnected() && (inputStatus == KEYBOARD_TYPING))
     {
         selEnd = currDoc.Application.Selection.End;
         if (selEnd > selStart)
         {
             rng = currDoc.Range(selStart, selEnd);
             rng.Select();
             GUIManager.display();
             inputStatus = KEYBOARD_PREFLISTSHOWED;
             Communicator.pushText(rng.Text.ToString(), 0);
             tempList = Communicator.getResult();
             GUIManager.passList(tempList);
             maxPage = tempList.Count / REFERENCE_PER_PAGE;
             GUIManager.chooseItem(0, 0);
             countDown.Stop();
         }
         else
         {
             selStart = selEnd;
             resetTimer();
         }
     }
 }
Exemplo n.º 22
0
        static void docProcess(string filename, string savejsontxtfile)
        {
            Word.Application wordApp = new Word.Application();
            Word.Document    wordDoc = new Word.Document();

            if (!System.IO.File.Exists(filename))
            {
                Console.WriteLine(filename + " 文件不存在");
                return;
            }

            try
            {
                wordDoc = wordApp.Documents.Open(filename);
            }
            catch (Exception err)
            {
                Console.WriteLine("pdf 文件打开异常");
                return;
            }
            wordApp.Visible = false;


            List <String[, ]> tableDataList = getTableDataList(wordDoc);
            List <Word.Range> TablesRanges  = getTableRangeList(wordDoc);


            //遍历所有段落,找出表格
            ArrayList docDataList = new ArrayList();
            //
            Boolean bInTable;
            //
            int table_i = -1;
            int doc_i   = 0;

            String[,] part_data = new String[1, 1];
            //
            string part_string;

            for (int pi = 0; pi <= wordDoc.Paragraphs.Count; pi++)
            {
                bInTable = false;
                try
                {
                    Word.Range r = wordDoc.Paragraphs[pi].Range;

                    part_string = r.Text;

                    //Console.WriteLine(">>");
                    //Console.WriteLine(part_string);

                    for (int i = 0; i < TablesRanges.Count; i++)
                    {
                        if (r.Start >= TablesRanges[i].Start && r.Start < TablesRanges[i].End)
                        {
                            //Console.WriteLine(">>>");
                            //Console.WriteLine(part_string);

                            bInTable = true;
                            if (i > table_i)
                            {
                                table_i = i;
                            }
                            break;
                        }
                    }

                    if (bInTable == false)
                    {
                        //Console.WriteLine("part---::::");
                        //Console.WriteLine(part_string);

                        docDataList.Add(part_string);
                    }
                    else
                    {
                        if (table_i > doc_i)
                        {
                            docDataList.Add(tableDataList[table_i]);

                            doc_i = table_i;
                        }
                        bInTable = false;
                    }
                }
                catch (Exception ee)
                {
                    Console.WriteLine("解析失败:", ee.Message.ToString());
                }
            }

            string output = JsonConvert.SerializeObject(docDataList);

            writeJson(savejsontxtfile, output);

            Console.WriteLine("end");

            Console.WriteLine(output);

            // wordDoc.SaveAs("C:\\Users\\Administrator\\Desktop\\新建文件夹 (2)\\b\\3.doc");

            //关闭wordDoc文档
            wordDoc.Close();
            wordApp.Quit();
        }
Exemplo n.º 23
0
		public void DetermineRangeToSearch(out SearchAreaType eType)
		{
			// this is either a selection chunk or "the rest of the document" from the insertion point
			theRangeToSearch = Document.Application.Selection.Range.Duplicate;

			// to determine if this is a selection or not, see if the start and end insertation points
			//  are the same (i.e. no selection).
			// but we really don't want this to be considered a selection, if it's just one word, so
			//  make sure that there are at least two words selected before calling it a selection
			// also, if the location hasn't changed since our last Find or Replace, then it's also
			//  not a selection.
			if ((theRangeToSearch.Start == theRangeToSearch.End)
				|| !m_bLocationChanged
				|| (theRangeToSearch.Text.Trim().IndexOf(' ') == -1))
			{
				ChangeToRestOfDocument(ref theRangeToSearch, out eType);
			}
			else
			{
				eType = SearchAreaType.eSelection;
			}

			// we call this function whenever the location has changed. In both cases, we then
			//  want to restart the search from the beginning paragraph of the range.
			m_paraSearch = null;
		}
Exemplo n.º 24
0
        private void CreateNewFile(Word.Application application, Person[] peoples, string fileOutDirectory = "", string filenameTemplate = "confirmation", int page = 0)
        {
            //Test if template exists
            if (File.Exists((string)templateDirPath))
            {
                //Get the full path of the document
                object p = Path.GetFullPath((string)templateDirPath);
                //Getting instance of the document !Readonly is only in case if it was already open!
                Word.Document document = application.Documents.Open(ref p, ReadOnly: true);
                //Set the document is active on the main world instance
                document.Activate();
                //Get the first and the only table on the document
                Word.Table table = document.Tables[1];

                // Replace End date
                Word.Find findObject = application.Selection.Find;
                findObject.ClearFormatting();
                findObject.Text = "{T_DATE}";
                findObject.Replacement.ClearFormatting();
                findObject.Replacement.Text = $"{DateTime.Now.ToShortDateString()}";
                findObject.Execute(Replace: Word.WdReplace.wdReplaceAll);


                foreach (Word.Section item in document.Sections)
                {
                    Word.Range r = item.Headers[Word.WdHeaderFooterIndex.wdHeaderFooterPrimary].Range;
                    r.Find.Execute(FindText: "{DATE}", ReplaceWith: $"{DateTime.Now.ToShortDateString()}", Replace: Word.WdReplace.wdReplaceAll);
                }


                //Iterate over each person and adding its info to the table
                for (int i = 0; i < peoples.Length; i++)
                {
                    /*
                     * Table start from one and not like a array from zero,
                     * The first row is for titles so we need to offset our self,
                     * from the second row so we need to offset by two
                     */

                    // Check in the person is valid no empty strings
                    if (peoples[i].IsValid())
                    {
                        //Add a row where the info would be entered
                        table.Rows.Add();
                        //Enter data to row
                        table.Cell(i + 2, 1).Range.Text = peoples[i].name;
                        table.Cell(i + 2, 2).Range.Text = peoples[i].passportNumber;
                    }
                }
                //Generate the new file name
                object filename = $"{filenameTemplate} {page + 1}.pdf";
                //Get the path for saving the file
                p = Path.Combine(fileOutDirectory, (string)filename);
                p = Path.GetFullPath((string)p);

                //Save as PDF savedas2 is from the MSDN website
                document.SaveAs2(ref p, Word.WdSaveFormat.wdFormatPDF);
                //Close the active documents and not saving any changes
                document.Close(Word.WdSaveOptions.wdDoNotSaveChanges);
            }
            else
            {
                throw new FileNotFoundException("Template not found");
            }
        }
Exemplo n.º 25
0
 protected virtual bool ShouldSplit(Word.Range first, Word.Range second)
 {
     return(!second.Font.IsSame(first.Characters.First.Font));
 }
Exemplo n.º 26
0
 public void resetExtensionMode()
 {
     unhighlight(extensionRange);
     extensionRange = null;
     extensionMode = false;
     extensions = null;
     paragraphPos = null;
     currentExtensionPosWordList = null;
     isCompletingLastSentenceOfPara = false;
     extensionType = -1;
     extensionPos = -1;
     extensionWordPos = -1;
 }
Exemplo n.º 27
0
        public ICharacters CreateFromRange(nat.Range range)
        {
            var charList = CreateCharList(range);

            return(new Characters(charList));
        }
Exemplo n.º 28
0
 public void setExtensionRange(Word.Range range)
 {
     this.extensionRange = range;
 }
Exemplo n.º 29
0
        /// <summary>
        /// Creates a vertical table in Word
        /// </summary>
        /// <param name="dt"></param>
        /// <param name="headerText"></param>
        /// <param name="header"></param>
        public override void CreateVerticalTable(DataTable dt, string headerText, bool header)
        {
            // test preconditions
            base.CreateVerticalTable(dt, headerText, header);

            // need a counter to get word rows
            int counter = 1;

            // try to print data out
            try
            {
                // get rid of the description column
                if (dt.Columns.Contains("Description"))
                {
                    dt.Columns.Remove("Description");
                }

                // create header
                if (header)
                {
                    CreateHeader(headerText);
                }

                // add another paragraph
                Word.Paragraph paragraph = document.Paragraphs.Add();
                Word.Range     range     = paragraph.Range;

                // create the entire table with styling
                Word.Table table = document.Tables.Add(range, dt.Rows.Count + 1, dt.Columns.Count,
                                                       Word.WdDefaultTableBehavior.wdWord9TableBehavior, Word.WdAutoFitBehavior.wdAutoFitFixed);
                table.Range.Cells.VerticalAlignment = Word.WdCellVerticalAlignment.wdCellAlignVerticalCenter;
                table.Rows.Alignment           = Word.WdRowAlignment.wdAlignRowCenter;
                table.PreferredWidth           = app.InchesToPoints(7.0F);
                table.Borders.InsideLineStyle  = Word.WdLineStyle.wdLineStyleNone;
                table.Borders.OutsideLineStyle = Word.WdLineStyle.wdLineStyleNone;
                table.Range.Font.Size          = 8;

                if (header == true)
                {
                    // create header row
                    Word.Range headerRange = table.Rows[counter].Range;
                    headerRange.Bold      = 1;
                    headerRange.Font.Name = "Arial";
                    headerRange.Cells.VerticalAlignment        = Word.WdCellVerticalAlignment.wdCellAlignVerticalCenter;
                    headerRange.Rows.Height                    = 24;
                    headerRange.Font.ColorIndex                = Word.WdColorIndex.wdWhite;
                    headerRange.Shading.BackgroundPatternColor = (Word.WdColor)ColorTranslator.ToOle(Color.FromArgb(23, 64, 109));
                    for (int i = 0; i < dt.Columns.Count; i++)
                    {
                        headerRange.Cells[i + 1].Range.Text        = Utilities.SpaceCapitalizedNames(dt.Columns[i].ToString());
                        headerRange.Cells[i + 1].VerticalAlignment = Word.WdCellVerticalAlignment.wdCellAlignVerticalCenter;
                    }
                    // don't create more
                    header = false;
                    counter++;
                }

                foreach (DataRow row in dt.Rows)
                {
                    // apply data styling
                    Word.Range rowRange = table.Rows[counter].Range;
                    table.Rows[counter].Height = 24;
                    rowRange.Bold            = 0;
                    rowRange.Font.Name       = "Arial";
                    rowRange.Font.Size       = 8;
                    rowRange.Font.ColorIndex = Word.WdColorIndex.wdBlack;

                    // alternate row colors
                    if (counter % 2 == 0)
                    {
                        rowRange.Shading.BackgroundPatternColor = (Word.WdColor)ColorTranslator.ToOle(Color.WhiteSmoke);
                    }
                    else
                    {
                        rowRange.Shading.BackgroundPatternColor = (Word.WdColor)ColorTranslator.ToOle(Color.FromArgb(220, 233, 238));
                    }

                    // get all field values and apply to the data table
                    for (int i = 0; i < dt.Columns.Count; i++)
                    {
                        if (dt.Columns[i].ColumnName == "ID")
                        {
                            string hyperlinkText = settings["Team Project Path"] + settings["Project Name"] + "/_workitems#_a=edit&id=" + row[i].ToString() + "&triage=true";
                            rowRange.Cells[i + 1].Range.Text = Utilities.ImplicitMalloc(row[i].ToString(), 6);
                            rowRange.Cells[i + 1].Range.Bold = 1;
                            rowRange.Cells[i + 1].Range.Hyperlinks.Add(document.Range(rowRange.Cells[i + 1].Range.Start, rowRange.Cells[i + 1].Range.End),
                                                                       hyperlinkText, Type.Missing, "Work Item", row[i].ToString(), Type.Missing);
                        }
                        else
                        {
                            rowRange.Cells[i + 1].Range.Text = row[i].ToString();
                        }
                    }
                    counter++;
                }

                // split
                InsertTableSplit(paragraph);
            }
            catch (Exception e)
            {
                // log
                this.logger.SetLoggingType(Logger.Type.Error)
                .SetMessage("Table could not be created. " + e.Message)
                .Display();

                // create error message
                CreateErrorMessage(e.Message);
            }
        }
Exemplo n.º 30
0
 // конструктор принимает обьект Range
 public WordSelection(Word.Range inputRange) : this(inputRange, true, true)
 {
 }
Exemplo n.º 31
0
        private void Export_Word_Click(object sender, RoutedEventArgs e)
        {
            var allUsers      = _context.Билет.ToList();
            var allCategories = _context.Клиент.ToList();

            var application = new Word.Application();

            Word.Document document = application.Documents.Add();

            foreach (var user in allUsers)
            {
                Word.Paragraph userParagrapth = document.Paragraphs.Add();
                Word.Range     userRange      = userParagrapth.Range;
                userRange.Text = user.Код_заказа + " " + user.Код_сотрудника;
                userParagrapth.set_Style("Обычный");
                userRange.InsertParagraphAfter();

                Word.Paragraph tableParagraph = document.Paragraphs.Add();
                Word.Range     tableRange     = tableParagraph.Range;
                Word.Table     paymentsTable  = document.Tables.Add(tableRange, allCategories.Count() + 1, 3);
                paymentsTable.Borders.InsideLineStyle       = paymentsTable.Borders.OutsideLineStyle = Word.WdLineStyle.wdLineStyleSingle;
                paymentsTable.Range.Cells.VerticalAlignment = Word.WdCellVerticalAlignment.wdCellAlignVerticalCenter;

                Word.Range cellRange;

                cellRange      = paymentsTable.Cell(1, 1).Range;
                cellRange.Text = "Иконка";
                cellRange      = paymentsTable.Cell(1, 2).Range;
                cellRange.Text = "Категория";
                cellRange      = paymentsTable.Cell(1, 3).Range;
                cellRange.Text = "Сумма расходов";

                paymentsTable.Rows[1].Range.Bold = 1;
                paymentsTable.Rows[1].Range.ParagraphFormat.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;

                for (int i = 0; i < allCategories.Count(); i++)
                {
                    var currentCategory = allCategories[i];

                    cellRange = paymentsTable.Cell(i + 2, 1).Range;
                    Word.InlineShape imageShape = cellRange.InlineShapes.AddPicture(AppDomain.CurrentDomain.BaseDirectory + "\\Assets\\" + currentCategory.icon);
                    imageShape.Width = imageShape.Height = 40;
                    cellRange.ParagraphFormat.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;

                    cellRange      = paymentsTable.Cell(i + 2, 2).Range;
                    cellRange.Text = currentCategory.телефон;

                    cellRange      = paymentsTable.Cell(i + 2, 3).Range;
                    cellRange.Text = user.Заказ.ToList().Where(p => p.Код_клиента == currentCategory.Код_клиента).Sum(p => p.Код_заказа * p.Код_клиента).ToString("N2") + "руб";
                }
                Заказ maxPayment = user.Заказ.OrderByDescending(p => p.Код_заказа * p.Код_клиента).FirstOrDefault();

                if (maxPayment != null)
                {
                    Word.Paragraph maxPaymentParagraph = document.Paragraphs.Add();
                    Word.Range     maxPaymentRange     = maxPaymentParagraph.Range;
                    maxPaymentRange.Text = $"Самый дорогостоящий платеж - {maxPayment.Дата_оформления} за {(maxPayment.Код_заказа * maxPayment.Код_клиента).ToString("N2")} ";
                    maxPaymentRange.set_Style("Выделенная цитата");
                    maxPaymentRange.Font.Color = Word.WdColor.wdColorDarkRed;
                    maxPaymentRange.InsertParagraphAfter();
                }

                Заказ minPayment = user.Заказ.OrderBy(p => p.Код_заказа * p.Код_клиента).FirstOrDefault();

                if (minPayment != null)
                {
                    Word.Paragraph minPaymentParagraph = document.Paragraphs.Add();
                    Word.Range     minPaymentRange     = minPaymentParagraph.Range;
                    minPaymentRange.Text = $"Самый дешевый платеж - {minPayment.Дата_оформления} за {(minPayment.Код_заказа * minPayment.Код_клиента).ToString("N2")} ";
                    minPaymentRange.set_Style("Выделенная цитата");
                    minPaymentRange.Font.Color = Word.WdColor.wdColorDarkGreen;
                    minPaymentRange.InsertParagraphAfter();
                }

                if (user != allUsers.LastOrDefault())
                {
                    document.Words.Last.InsertBreak(Word.WdBreakType.wdPageBreak);
                }
            }
            application.Visible = true;

            document.SaveAs(@"D:\для с#\программные решения для бизнеса\diagramms\diagramms\packages\Test.docx");
            document.SaveAs(@"D:\для с#\программные решения для бизнеса\diagramms\diagramms\packages\Test.pdf", Word.WdExportFormat.wdExportFormatPDF);
        }
Exemplo n.º 32
0
 public WordSelection(Word.Range inputRange, bool insertParagrAfterText)
     : this(inputRange, insertParagrAfterText, true)
 {
 }
Exemplo n.º 33
0
        public static void exportAccounts(List <Account> accounts)
        {
            Word.Application wordApp = new Word.Application();
            wordApp.ShowAnimation = false;
            wordApp.Visible       = false;
            object missingValue = System.Reflection.Missing.Value;

            Word.Document document = wordApp.Documents.Add(ref missingValue, ref missingValue, ref missingValue, ref missingValue);

            foreach (Word.Section section in document.Sections)
            {
                Word.Range headerRange = section.Headers[Word.WdHeaderFooterIndex.wdHeaderFooterPrimary].Range;
                headerRange.Fields.Add(headerRange, Word.WdFieldType.wdFieldPage);
                headerRange.ParagraphFormat.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;
                headerRange.Font.ColorIndex           = Word.WdColorIndex.wdBlue;
                headerRange.Font.Size = 12;
                headerRange.Text      = "List of accounts";
            }

            foreach (Word.Section section in document.Sections)
            {
                Word.Range footerRange = section.Footers[Word.WdHeaderFooterIndex.wdHeaderFooterPrimary].Range;
                footerRange.Font.ColorIndex           = Word.WdColorIndex.wdDarkRed;
                footerRange.Font.Size                 = 12;
                footerRange.ParagraphFormat.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;
                footerRange.Text = "Programming Engineering";
            }

            document.Content.SetRange(0, 0);
            foreach (Account account in accounts)
            {
                document.Content.Text = "Account details" + Environment.NewLine;

                Word.Paragraph accountNumberParagraph = document.Content.Paragraphs.Add(ref missingValue);
                object         styleHeading           = "Heading 2";
                accountNumberParagraph.set_Style(styleHeading);
                accountNumberParagraph.Range.Text = "Account Number: " + account.AccountNo;
                accountNumberParagraph.Range.InsertParagraphAfter();

                Word.Paragraph accountTypeParagraph = document.Content.Paragraphs.Add(ref missingValue);
                accountTypeParagraph.set_Style(styleHeading);
                accountTypeParagraph.Range.Text = "Account Type: " + account.AccountType;
                accountTypeParagraph.Range.InsertParagraphAfter();

                Word.Paragraph currencyParagraph = document.Content.Paragraphs.Add(ref missingValue);
                currencyParagraph.set_Style(styleHeading);
                currencyParagraph.Range.Text = "Currency: " + account.Currency;
                currencyParagraph.Range.InsertParagraphAfter();

                Word.Paragraph amountParagraph = document.Content.Paragraphs.Add(ref missingValue);
                amountParagraph.set_Style(styleHeading);
                amountParagraph.Range.Text = "Amount: " + account.Ammount;
                amountParagraph.Range.InsertParagraphAfter();

                Word.Paragraph openDateParagraph = document.Content.Paragraphs.Add(ref missingValue);
                openDateParagraph.set_Style(styleHeading);
                openDateParagraph.Range.Text = "Open Date: " + account.OpenDate;
                openDateParagraph.Range.InsertParagraphAfter();
            }

            object filename = @"C:\Accounts.docx";

            document.SaveAs2(ref filename);
            document.Close(ref missingValue, ref missingValue, ref missingValue);
            document = null;
            wordApp.Quit(ref missingValue, ref missingValue, ref missingValue);
            wordApp = null;
        }
Exemplo n.º 34
0
        private void CreateDocument()
        {
            try
            {
                //khoi dong word
                Microsoft.Office.Interop.Word.Application winword = new Microsoft.Office.Interop.Word.Application();

                //tao animation
                winword.ShowAnimation = false;

                //hide word app
                winword.Visible = false;
                object missing = System.Reflection.Missing.Value;

                //tao document
                Microsoft.Office.Interop.Word.Document document = winword.Documents.Add(ref missing, ref missing, ref missing, ref missing);

                //them header
                foreach (Microsoft.Office.Interop.Word.Section section in document.Sections)
                {
                    //Get the header range and add the header details.
                    Microsoft.Office.Interop.Word.Range headerRange = section.Headers[Microsoft.Office.Interop.Word.WdHeaderFooterIndex.wdHeaderFooterPrimary].Range;
                    headerRange.Fields.Add(headerRange, Microsoft.Office.Interop.Word.WdFieldType.wdFieldPage);
                    headerRange.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
                    headerRange.Font.ColorIndex           = Microsoft.Office.Interop.Word.WdColorIndex.wdBlue;
                    headerRange.Font.Size = 14;
                    headerRange.Text      = "BÁO CÁO THỐNG KÊ DU HỌC SINH";
                }

                //them footer
                foreach (Microsoft.Office.Interop.Word.Section wordSection in document.Sections)
                {
                    //Get the footer range and add the footer details.
                    Microsoft.Office.Interop.Word.Range footerRange = wordSection.Footers[Microsoft.Office.Interop.Word.WdHeaderFooterIndex.wdHeaderFooterPrimary].Range;
                    footerRange.Font.ColorIndex           = Microsoft.Office.Interop.Word.WdColorIndex.wdDarkRed;
                    footerRange.Font.Size                 = 14;
                    footerRange.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
                    footerRange.Text = "";
                }

                //adding text to document
                document.Content.SetRange(0, 0);
                document.Content.Text = "Báo cáo thống kê du học sinh trong năm qua :  " + Environment.NewLine;

                //thêm đoạn văn 1
                Microsoft.Office.Interop.Word.Paragraph para1 = document.Content.Paragraphs.Add(ref missing);
                object styleHeading1 = "Heading 1";
                para1.Range.set_Style(ref styleHeading1);
                para1.Range.Text = "Para 1 text";
                para1.Range.InsertParagraphAfter();
                //thêm đoạn văn 2
                Microsoft.Office.Interop.Word.Paragraph para2 = document.Content.Paragraphs.Add(ref missing);
                object styleHeading2 = "Heading 2";
                para2.Range.set_Style(ref styleHeading2);
                para2.Range.Text = "Para 2 text";
                para2.Range.InsertParagraphAfter();

                //thêm bảng 5x5
                Table firstTable = document.Tables.Add(para1.Range, 5, 5, ref missing, ref missing);

                firstTable.Borders.Enable = 1;
                foreach (Row row in firstTable.Rows)
                {
                    foreach (Cell cell in row.Cells)
                    {
                        //Header row
                        if (cell.RowIndex == 1)
                        {
                            cell.Range.Text      = "Column " + cell.ColumnIndex.ToString();
                            cell.Range.Font.Bold = 1;
                            //other format properties goes here
                            cell.Range.Font.Name = "verdana";
                            cell.Range.Font.Size = 10;
                            //cell.Range.Font.ColorIndex = WdColorIndex.wdGray25;
                            cell.Shading.BackgroundPatternColor = WdColor.wdColorGray25;
                            //Center alignment for the Header cells
                            cell.VerticalAlignment = WdCellVerticalAlignment.wdCellAlignVerticalCenter;
                            cell.Range.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphCenter;
                        }
                        //Data row
                        else
                        {
                            cell.Range.Text = (cell.RowIndex - 2 + cell.ColumnIndex).ToString();
                        }
                    }
                }

                //Save the document
                object filename = @"c:\temp1.docx";
                document.SaveAs2(ref filename);
                document.Close(ref missing, ref missing, ref missing);
                document = null;
                winword.Quit(ref missing, ref missing, ref missing);
                winword = null;
            }
            catch (Exception)
            {
            }
        }
Exemplo n.º 35
0
 /// <summary>
 /// 文書の末尾に改行を追加する
 /// </summary>
 /// <returns></returns>
 private static void AddParagraph(Word.Application wordApp, ref Word.Document document)
 {
     Word.Range rng = document.Range(document.Content.End - 1, document.Content.End - 1);
     document.Content.Paragraphs.Add(rng);
 }
Exemplo n.º 36
0
        //Eksportirane v Word
        private void buttonExport_Click(object sender, EventArgs e)
        {
            ConnectionManager connectionManager = new ConnectionManager();
            var wordApp = new Word.Application();

            wordApp.Visible = true;
            wordApp.Documents.Add();
            Word.Document      doc          = wordApp.ActiveDocument;
            object             missing      = System.Reflection.Missing.Value;
            List <Appointment> appointments = connectionManager.GetAppointementsInLast30Days(patient);

            Word.Paragraph par = doc.Content.Paragraphs.Add(ref missing);
            //Zaglaven red na otcheta i formatiraneto mu
            par.Range.Text      = "Information for patient No " + patient.id;
            par.Range.Font.Size = 26;
            par.Range.Font.Name = "Bahnschrift";
            par.Alignment       = Word.WdParagraphAlignment.wdAlignParagraphCenter;
            par.Range.InsertParagraphAfter();

            //Redove s informaciq za pacienta i formatiraneto im
            string[,] data = new string[, ]
            {
                { "Firstname", labelFM.Text },
                { "Middlename", labelMN.Text },
                { "Last Name", labelLN.Text },
                { "EGN", labelEGN.Text },
                { "Gender", labelGender.Text },
                { "Birthday", labelBirthday.Text }
            };



            for (int i = 0; i < data.GetLength(0); i++)
            {
                par.Range.Font.Size = 14;
                par.Range.Text      = data[i, 0] + ": " + data[i, 1];
                par.Alignment       = Word.WdParagraphAlignment.wdAlignParagraphLeft;
                par.Range.InsertParagraphAfter();
            }

            //Zaglaven red za informaciata za diagnozi prez poslednite 30 dena i formatiraneto mu
            par.Alignment       = Word.WdParagraphAlignment.wdAlignParagraphCenter;
            par.Range.Font.Size = 20;
            par.Range.Text      = "Diagnoses in last 30 days:";
            par.Range.InsertParagraphAfter();
            par.Alignment       = Word.WdParagraphAlignment.wdAlignParagraphLeft;
            par.Range.Font.Size = 12;

            //informaciata za diagnozi prez poslednite 30 dena i formatirane
            if (appointments.Count == 0)
            {
                par.Range.Text = "Patient was not diagnosed in the last 30 days.";
            }
            else
            {
                for (int i = 0; i < appointments.Count; i++)
                {
                    par.Range.Text = "On " + appointments[i].date.ToString("dd/MM/yyyy") + " patient was diagnosed with " + appointments[i].diagnosis + ".";
                    par.Range.InsertParagraphAfter();
                }
            }

            //Dobavqne na footer s data
            foreach (Word.Section section in doc.Sections)
            {
                Word.Range footer = section.Footers[Word.WdHeaderFooterIndex.wdHeaderFooterPrimary].Range;
                footer.Text = DateTime.Now.ToString();
            }
        }
Exemplo n.º 37
0
        private void CreateDocumentPropertyTable(Document newDocument)
        {
            //<Snippet90>
            object start = 10, end = 10;

            Word.Range rangeTbl = null;
            string     keys     = "[tbl]";

            while (newDocument.Content.Find.Execute(FindText: keys))
            {
                if (newDocument.Content.Find.Execute(FindText: keys))
                {
                    if (newDocument.Application.Selection.Find.Execute(keys) == true)
                    {
                        rangeTbl = newDocument.Range(newDocument.Application.Selection.Range.Start, newDocument.Application.Selection.Range.End);
                    }
                }
            }

            //if (newDocument.Application.Selection.Find.Execute("[tbl]"))
            //{
            //    rangeTbl = newDocument.Range(newDocument.Application.Selection.Range.Start, newDocument.Application.Selection.Range.End);
            //}

            Word.Range rng = newDocument.Range(rangeTbl.Start, rangeTbl.End);
            //</Snippet90>

            // Insert a title for the table and paragraph marks.
            //<Snippet91>
            //rng.InsertBefore("Document Statistics");
            rng.Font.Name = "Calibri (Body)";
            rng.Font.Size = 16;
            rng.InsertParagraphAfter();
            rng.InsertParagraphAfter();
            rng.SetRange(rng.End, rng.End);
            //</Snippet91>

            // Add the table.
            //<Snippet92>
            rng.Tables.Add(newDocument.Paragraphs[2].Range, 3, 2);
            //</Snippet92>

            // Format the table and apply a style.
            //<Snippet93>
            Word.Table tbl = newDocument.Tables[1];
            tbl.Range.Font.Size = 12;
            tbl.Columns.DistributeWidth();

            object styleName = "Table Professional";

            tbl.set_Style(ref styleName);
            //</Snippet93>

            // Insert document properties into cells.
            //<Snippet94>
            tbl.Cell(1, 1).Range.Text = "Document Property";
            tbl.Cell(1, 2).Range.Text = "Value";

            tbl.Cell(2, 1).Range.Text = "Subject";
            tbl.Cell(2, 2).Range.Text = "Test";

            tbl.Cell(3, 1).Range.Text = "Author";
            tbl.Cell(3, 2).Range.Text = "test";
            //</Snippet94>
        }
Exemplo n.º 38
0
        public string getDocumentPdf2(DataTable dataExport, bool includeHeaders, bool includeTitles, List <string> headerTitles, string path, string fileName)
        {
            string filePath = "";
            object miss     = System.Reflection.Missing.Value;
            object end      = "\\endofdoc";

            Word.Application appWord = new Word.Application();
            Word.Document    docWord;
            docWord = appWord.Documents.Add(miss, miss, miss, miss);
            Word.Paragraph paragWord;
            paragWord = docWord.Content.Paragraphs.Add(miss);
            int fontSize = 16, column = 0, rowInfo = 1, head = 0;

            if (includeTitles)
            {
                for (int i = 0; i < headerTitles.Count; i++)
                {
                    paragWord.Range.Text        = headerTitles[i];
                    paragWord.Range.Font.Bold   = 1;
                    paragWord.Range.Font.Size   = fontSize;
                    paragWord.Format.SpaceAfter = 6;
                    paragWord.Range.InsertParagraphAfter();
                    fontSize = 12;
                }
            }

            if (includeHeaders)
            {
                head = 1;
            }
            object oRng = docWord.Bookmarks.get_Item(ref end).Range;

            Word.Table tableWord;
            Word.Range rangeWord = docWord.Bookmarks.get_Item(ref end).Range;
            tableWord = docWord.Tables.Add(rangeWord, dataExport.Rows.Count + head, dataExport.Columns.Count, ref miss, ref miss);
            tableWord.Range.ParagraphFormat.SpaceAfter = 6;
            if (includeHeaders)
            {
                foreach (DataColumn dataCol in dataExport.Columns)
                {
                    column++;
                    tableWord.Cell(rowInfo, column).Range.Text = dataCol.ColumnName;
                }
                rowInfo += 1;
                tableWord.Rows[1].Range.Font.Bold   = 1;
                tableWord.Rows[1].Range.Font.Italic = 1;
            }

            for (int i = 0; i < dataExport.Rows.Count; i++)
            {
                for (int j = 0; j < dataExport.Columns.Count; j++)
                {
                    tableWord.Cell(i + rowInfo, j + 1).Range.Text = dataExport.Rows[i][j].ToString();
                }
            }


            for (int i = rowInfo; i <= dataExport.Rows.Count + 1; i++)
            {
                tableWord.Rows[i].Range.Font.Bold = 0;
            }
            tableWord.Borders[Word.WdBorderType.wdBorderVertical].LineStyle   = Word.WdLineStyle.wdLineStyleSingle;
            tableWord.Borders[Word.WdBorderType.wdBorderLeft].LineStyle       = Word.WdLineStyle.wdLineStyleSingle;
            tableWord.Borders[Word.WdBorderType.wdBorderRight].LineStyle      = Word.WdLineStyle.wdLineStyleSingle;
            tableWord.Borders[Word.WdBorderType.wdBorderHorizontal].LineStyle = Word.WdLineStyle.wdLineStyleSingle;
            tableWord.Borders[Word.WdBorderType.wdBorderTop].LineStyle        = Word.WdLineStyle.wdLineStyleSingle;
            tableWord.Borders[Word.WdBorderType.wdBorderBottom].LineStyle     = Word.WdLineStyle.wdLineStyleSingle;
            filePath = path + @"\" + fileName + ".pdf";
            docWord.ExportAsFixedFormat(filePath, Word.WdExportFormat.wdExportFormatPDF);
            docWord.Close(Word.WdSaveOptions.wdDoNotSaveChanges, Type.Missing, Type.Missing);
            try
            {
                foreach (System.Diagnostics.Process proceso in System.Diagnostics.Process.GetProcesses())
                {
                    if (proceso.ProcessName.Contains("WORD"))
                    {
                        proceso.Kill();
                    }
                }
            }
            catch (Exception)
            { }


            return(filePath);
        }
Exemplo n.º 39
0
        private string InitRead(string Template, Dictionary <string, string> datas, System.Data.DataTable dt, string userType, string year, string qymc)
        {
            Microsoft.Office.Interop.Word.Application app = null;
            Microsoft.Office.Interop.Word.Document    doc = null;
            //将要导出的新word文件名
            string physicNewFile = DateTime.Now.ToString("yyyyMMddHHmmssss") + ".doc";

            try
            {
                app         = new Microsoft.Office.Interop.Word.Application();             //创建word应用程序
                app.Visible = false;
                object fileName = System.Windows.Forms.Application.StartupPath + Template; //Year1;//模板文件
                //打开模板文件
                object oMissing = System.Reflection.Missing.Value;
                doc = app.Documents.Open(ref fileName,
                                         ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
                                         ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
                                         ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing);



                object replace = Microsoft.Office.Interop.Word.WdReplace.wdReplaceAll;
                foreach (var item in datas)
                {
                    app.Selection.Find.Replacement.ClearFormatting();
                    app.Selection.Find.ClearFormatting();
                    app.Selection.Find.Text             = item.Key;   //需要被替换的文本
                    app.Selection.Find.Replacement.Text = item.Value; //替换文本

                    //执行替换操作
                    app.Selection.Find.Execute(
                        ref oMissing, ref oMissing,
                        ref oMissing, ref oMissing,
                        ref oMissing, ref oMissing,
                        ref oMissing, ref oMissing, ref oMissing,
                        ref oMissing, ref replace,
                        ref oMissing, ref oMissing,
                        ref oMissing, ref oMissing);
                }

                object unit;
                unit = Microsoft.Office.Interop.Word.WdUnits.wdStory;
                app.Selection.EndKey(ref unit, ref oMissing);
                app.Selection.TypeParagraph(); //插入段落

                if (userType == "C")           //国产
                {
                    app.Selection.Text = String.Format("{0}年{1}企业国产乘用车产品燃料消耗量", year.Substring(0, 4), qymc);
                    Word.Range range = doc.Paragraphs.Last.Range;
                    Microsoft.Office.Interop.Word.Table table = app.Selection.Tables.Add(range, dt.Rows.Count + 1, 12, ref oMissing, ref oMissing);
                    //设置表格的字体大小粗细
                    table.Range.Font.Size = 10;
                    table.Range.Font.Bold = 0;
                    //为表格划线
                    range.Tables[1].Borders[WdBorderType.wdBorderTop].LineStyle        = WdLineStyle.wdLineStyleSingle;
                    range.Tables[1].Borders[WdBorderType.wdBorderLeft].LineStyle       = WdLineStyle.wdLineStyleSingle;
                    range.Tables[1].Borders[WdBorderType.wdBorderRight].LineStyle      = WdLineStyle.wdLineStyleSingle;
                    range.Tables[1].Borders[WdBorderType.wdBorderBottom].LineStyle     = WdLineStyle.wdLineStyleSingle;
                    range.Tables[1].Borders[WdBorderType.wdBorderHorizontal].LineStyle = WdLineStyle.wdLineStyleSingle;
                    range.Tables[1].Borders[WdBorderType.wdBorderVertical].LineStyle   = WdLineStyle.wdLineStyleSingle;

                    //设置表格标题
                    table.Cell(1, 1).Range.Text  = "序号";
                    table.Cell(1, 2).Range.Text  = "汽车生产企业";
                    table.Cell(1, 3).Range.Text  = "车辆型号";
                    table.Cell(1, 4).Range.Text  = "燃料种类";
                    table.Cell(1, 5).Range.Text  = "整车整备质量";
                    table.Cell(1, 6).Range.Text  = "变速器型式";
                    table.Cell(1, 7).Range.Text  = "座位排数";
                    table.Cell(1, 8).Range.Text  = "纯电动驱动模式综合工况续驶里程";
                    table.Cell(1, 9).Range.Text  = "车型燃料消耗量目标值①";
                    table.Cell(1, 10).Range.Text = "综合工况燃烧消耗量实际值②";
                    table.Cell(1, 11).Range.Text = "实际生产量③";
                    table.Cell(1, 12).Range.Text = "备注";

                    //循环数据创建数据行
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        table.Cell(i + 2, 1).Range.Text  = (i + 1).ToString();
                        table.Cell(i + 2, 2).Range.Text  = dt.Rows[i]["Qcscqy"].ToString();
                        table.Cell(i + 2, 3).Range.Text  = dt.Rows[i]["Clxh"].ToString();
                        table.Cell(i + 2, 4).Range.Text  = dt.Rows[i]["Rllx"].ToString();
                        table.Cell(i + 2, 5).Range.Text  = dt.Rows[i]["Zczbzl"].ToString();
                        table.Cell(i + 2, 6).Range.Text  = dt.Rows[i]["Bsqxs"].ToString();
                        table.Cell(i + 2, 7).Range.Text  = dt.Rows[i]["Zwps"].ToString();
                        table.Cell(i + 2, 8).Range.Text  = dt.Rows[i]["Zhgkxslc"].ToString();
                        table.Cell(i + 2, 9).Range.Text  = dt.Rows[i]["TgtZhgkrlxhl"].ToString();
                        table.Cell(i + 2, 10).Range.Text = dt.Rows[i]["ActZhgkrlxhl"].ToString();
                        table.Cell(i + 2, 11).Range.Text = dt.Rows[i]["Sl_act"].ToString();
                    }
                }
                else  //进口
                {
                    app.Selection.Text = String.Format("{0}年{1}企业进口乘用车产品燃料消耗量", year.Substring(0, 4), qymc);
                    Word.Range range = doc.Paragraphs.Last.Range;
                    Microsoft.Office.Interop.Word.Table table = app.Selection.Tables.Add(range, dt.Rows.Count + 1, 12, ref oMissing, ref oMissing);
                    //设置表格的字体大小粗细
                    table.Range.Font.Size = 10;
                    table.Range.Font.Bold = 0;
                    //为表格划线
                    range.Tables[1].Borders[WdBorderType.wdBorderTop].LineStyle        = WdLineStyle.wdLineStyleSingle;
                    range.Tables[1].Borders[WdBorderType.wdBorderLeft].LineStyle       = WdLineStyle.wdLineStyleSingle;
                    range.Tables[1].Borders[WdBorderType.wdBorderRight].LineStyle      = WdLineStyle.wdLineStyleSingle;
                    range.Tables[1].Borders[WdBorderType.wdBorderBottom].LineStyle     = WdLineStyle.wdLineStyleSingle;
                    range.Tables[1].Borders[WdBorderType.wdBorderHorizontal].LineStyle = WdLineStyle.wdLineStyleSingle;
                    range.Tables[1].Borders[WdBorderType.wdBorderVertical].LineStyle   = WdLineStyle.wdLineStyleSingle;

                    //设置表格标题
                    table.Cell(1, 1).Range.Text  = "序号";
                    table.Cell(1, 2).Range.Text  = "汽车生产企业";
                    table.Cell(1, 3).Range.Text  = "车辆型号";
                    table.Cell(1, 4).Range.Text  = "燃料种类";
                    table.Cell(1, 5).Range.Text  = "整车整备质量";
                    table.Cell(1, 6).Range.Text  = "变速器型式";
                    table.Cell(1, 7).Range.Text  = "座位排数";
                    table.Cell(1, 8).Range.Text  = "纯电动驱动模式综合工况续驶里程";
                    table.Cell(1, 9).Range.Text  = "车型燃料消耗量目标值①";
                    table.Cell(1, 10).Range.Text = "综合工况燃烧消耗量实际值②";
                    table.Cell(1, 11).Range.Text = "实际生产量③";
                    table.Cell(1, 12).Range.Text = "备注";

                    //循环数据创建数据行
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        table.Cell(i + 2, 1).Range.Text  = (i + 1).ToString();
                        table.Cell(i + 2, 2).Range.Text  = dt.Rows[i]["Qcscqy"].ToString();
                        table.Cell(i + 2, 3).Range.Text  = dt.Rows[i]["Clxh"].ToString();
                        table.Cell(i + 2, 4).Range.Text  = dt.Rows[i]["Rllx"].ToString();
                        table.Cell(i + 2, 5).Range.Text  = dt.Rows[i]["Zczbzl"].ToString();
                        table.Cell(i + 2, 6).Range.Text  = dt.Rows[i]["Bsqxs"].ToString();
                        table.Cell(i + 2, 7).Range.Text  = dt.Rows[i]["Zwps"].ToString();
                        table.Cell(i + 2, 8).Range.Text  = dt.Rows[i]["Zhgkxslc"].ToString();
                        table.Cell(i + 2, 9).Range.Text  = dt.Rows[i]["TgtZhgkrlxhl"].ToString();
                        table.Cell(i + 2, 10).Range.Text = dt.Rows[i]["ActZhgkrlxhl"].ToString();
                        table.Cell(i + 2, 11).Range.Text = dt.Rows[i]["Sl_act"].ToString();
                    }
                }

                unit = Microsoft.Office.Interop.Word.WdUnits.wdStory;
                app.Selection.EndKey(ref unit, ref oMissing);
                app.Selection.TypeParagraph();//插入段落


                app.Selection.Text = @"注:①车型燃料消耗量目标值,同一车辆型号因整车整备质量、座位排数、变速器形式不同有多个不同的燃料消耗量目标值时,计算企业平均消耗量目标值时采用最小的燃料消耗量目标值。
②综合工况燃料消耗量实际值,四舍五入至小数点后一位;如汽车燃料消耗量通告系统中同一车型有多个不同的综合工况燃料消耗量实际值,则填写该车型最高的综合工况燃料消耗量实际值。
③实际生产量/实际进口量,不含出口量。";


                //对替换好的word模板另存为一个新的word文档
                doc.SaveAs(System.Windows.Forms.Application.StartupPath + "\\ExcelHeaderTemplate\\" + physicNewFile,
                           oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing,
                           oMissing, oMissing, oMissing, oMissing, oMissing, oMissing);

                //准备导出word
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (doc != null)
                {
                    doc.Close();//关闭word文档
                }
                if (app != null)
                {
                    app.Quit();//退出word应用程序
                }
            }
            return(physicNewFile);
        }
Exemplo n.º 40
0
        private void WordGen()
        {
            Word._Application WordApplication;
            WordApplication         = new Word.Application();
            WordApplication.Visible = true;

            Word._Document Doc;
            Doc = WordApplication.Documents.Add();

            string EndOfDocFlag = "\\endofdoc";

            Word.Range AtEndOfDoc = Doc.Bookmarks.get_Item(EndOfDocFlag).Range;;

            /* 1 Page */

            // Source
            List <string> McuTableParameters = new List <string>(new string[] { "Model", "PinPackage", "Quartz Clock", "Core Clock", "Periperal 1 Clock", "Periperal 2 Clock", "Periperal 3 Clock" });
            List <string> McuTableValues     = new List <string>(new string[] { general_tab.ComboBox_McuModel.Text, general_tab.ComboBox_PinPackage.Text, general_tab.TextBox_Clock_Quartz.Text, general_tab.TextBox_Clock_Core.Text, general_tab.TextBox_Clock_Peripheral1.Text, general_tab.TextBox_Clock_Peripheral2.Text, general_tab.TextBox_Clock_Peripheral3.Text });
            List <string> ClockOutputParameters;
            List <string> ClockOutputValues;

            if (general_tab.CheckBox_ClockOutput.IsChecked == true)
            {
                ClockOutputParameters = new List <string>(new string[] { "Usage", "Source Clock", "Divider" });
                ClockOutputValues     = new List <string>(new string[] { "USE", "", general_tab.ComboBox_ClockOutput_Divider.Text });

                if (general_tab.RadioButton_ClockOutput_FIRC.IsChecked == true)
                {
                    ClockOutputValues[1] = "FIRC";
                }
                else
                if (general_tab.RadioButton_ClockOutput_FMPLL.IsChecked == true)
                {
                    ClockOutputValues[1] = "FMPLL";
                }
                else
                if (general_tab.RadioButton_ClockOutput_FXOSC.IsChecked == true)
                {
                    ClockOutputValues[1] = "FXOSC";
                }
            }
            else
            {
                ClockOutputParameters = new List <string>(new string[] { "Usage" });
                ClockOutputValues     = new List <string>(new string[] { "NOT USE" });
            }

            H1(ref Doc, "MCU");
            MakeVTable(ref Doc, "MCU General", McuTableParameters, McuTableValues);
            MakeVTable(ref Doc, "Clock Output", ClockOutputParameters, ClockOutputValues);
            BreakPage(ref Doc);
            H1(ref Doc, "OS");
            List <string> StackTableParameters = new List <string>(new string[] { "FG1 Task", "FG2 Task (Include Low Power Task)", "Event", "Background Task" });
            List <string> StackTableValues     = new List <string>(new string[] { os_tab.TextBox_Stack_FG1.Text, os_tab.TextBox_Stack_FG2.Text, os_tab.TextBox_Stack_Event.Text, os_tab.TextBox_Stack_BG.Text });

            MakeVTable(ref Doc, "Stack", StackTableParameters, StackTableValues);

            List <string> TaskTableParameters      = new List <string>(new string[] { "Name\n(Task_)", "Priority", "Auto\nStart", "Preemtive", "Offset\n(Periodic)", "Cycle\n(Periodic)" });
            List <string> TaskNameTableValues      = new List <string>();
            List <string> TaskPriorityTableValues  = new List <string>();
            List <string> TaskAutoStartTableValues = new List <string>();
            List <string> TaskPreemtiveTableValues = new List <string>();
            List <string> TaskOffsetTableValues    = new List <string>();
            List <string> TaskCycleTableValues     = new List <string>();

            foreach (Model.PlatformTask task in os_tab.DataGrid_Task.ItemsSource as IEnumerable)
            {
                TaskNameTableValues.Add(task.Name.Remove(0, 5));
                TaskPriorityTableValues.Add(task.Priority.ToString());
                TaskAutoStartTableValues.Add(task.Preemptive.ToString());
                TaskPreemtiveTableValues.Add(task.AutoStart.ToString());
                if (task.AlarmOffset == null)
                {
                    TaskOffsetTableValues.Add("-");
                }
                else
                {
                    TaskOffsetTableValues.Add(task.AlarmOffset.ToString());
                }
                if (task.AlarmCycle == null)
                {
                    TaskCycleTableValues.Add("-");
                }
                else
                {
                    TaskCycleTableValues.Add(task.AlarmCycle.ToString());
                }
            }
            MakeHTable(ref Doc, "Task", TaskTableParameters, TaskNameTableValues, TaskPriorityTableValues, TaskAutoStartTableValues, TaskPreemtiveTableValues, TaskOffsetTableValues, TaskCycleTableValues);

            List <string> DebugFuncTableParameters = new List <string>(new string[] { "CPU Load", "Interrupt Load", "Stack Depth", "Task Monitoring" });
            List <string> DebugFuncTableValues     = new List <string>(new string[] { os_tab.CpuLoad.IsChecked.ToString(), os_tab.ItLoad.IsChecked.ToString(), os_tab.StackDepth.IsChecked.ToString(), os_tab.TaskMonitoring.IsChecked.ToString() });

            MakeVTable(ref Doc, "Debug Function", DebugFuncTableParameters, DebugFuncTableValues);

            BreakPage(ref Doc);

            /* 2 Page */

            object szPath = "test.docx";

            Doc.SaveAs(ref szPath);
        }
Exemplo n.º 41
0
        private void button1_Click(object sender, EventArgs e)
        {
            Word.Document wd = new Word.Document();
            wd.Activate();
            Object start = Type.Missing;
            Object end   = Type.Missing;

            wd.Content.Font.Size = 12;
            wd.Content.Font.Name = "Times New Roman";
            wd.Content.ParagraphFormat.Alignment = Word.WdParagraphAlignment.wdAlignParagraphLeft;
            Word.Range rng = wd.Range(ref start, ref end);

            Word.Paragraph wordparagraph = wd.Paragraphs.Add();
            wordparagraph.Range.Text = "Государственное учреждение образования \"Институт бизнеса и менеджмента технологий\" Белорусского государственного университета";
            wordparagraph.Alignment  = Word.WdParagraphAlignment.wdAlignParagraphCenter;
            wordparagraph.Range.InsertParagraphAfter();

            wordparagraph.Range.Text      = "Карточка №1";
            wordparagraph.Range.Font.Size = 14;
            wordparagraph.Range.Bold      = 1;
            wordparagraph.Alignment       = Word.WdParagraphAlignment.wdAlignParagraphCenter;
            wordparagraph.Range.InsertParagraphAfter();

            wordparagraph.Range.Text      = "(учета проведенных занятий)";
            wordparagraph.Range.Font.Size = 14;
            wordparagraph.Range.Bold      = 1;
            wordparagraph.Alignment       = Word.WdParagraphAlignment.wdAlignParagraphCenter;
            wordparagraph.Range.InsertParagraphAfter();

            wordparagraph.Range.Text      = "Преподаватель\t" + lecturerName;
            wordparagraph.Range.Font.Size = 12;
            wordparagraph.Range.Bold      = 0;
            wordparagraph.Alignment       = Word.WdParagraphAlignment.wdAlignParagraphLeft;
            wordparagraph.Range.InsertParagraphAfter();

            wordparagraph.Range.Text = "Факультет бизнеса";
            wordparagraph.Range.InsertParagraphAfter();

            wordparagraph.Range.Text = "Специальность\t" + speciality;
            wordparagraph.Range.InsertParagraphAfter();

            wordparagraph.Range.Text = "Курс\t\t" + courseNum + "\t\tГруппа\t\t" + n;
            wordparagraph.Range.InsertParagraphAfter();

            wordparagraph.Range.Text = "Учебный год\t\t" + schoolYear + "\t\tСеместр\t\t" + semester.ToString();
            wordparagraph.Range.InsertParagraphAfter();

            wordparagraph.Range.Text = "Учебная дисциплина\t" + subject;
            wordparagraph.Range.InsertParagraphAfter();

            wordparagraph.Range.Text = "Количество часов по плану";
            wordparagraph.Range.InsertParagraphAfter();

            wordparagraph.Range.Text = "Форма занятий";
            wordparagraph.Range.InsertParagraphAfter();

            rng.SetRange(rng.End, rng.End);
            Object defaultTableBehavior = Type.Missing;
            Object autoFitBehavior      = Type.Missing;

            Word.Table tbl = wd.Tables.Add(rng, 1, 7, ref defaultTableBehavior, ref autoFitBehavior);
            SetHeadings(tbl.Cell(1, 1), "№ п/п");
            SetHeadings(tbl.Cell(1, 2), "Тема");
            SetHeadings(tbl.Cell(1, 3), "Тип");
            SetHeadings(tbl.Cell(1, 4), "Дата");
            SetHeadings(tbl.Cell(1, 5), "Время");
            SetHeadings(tbl.Cell(1, 6), "Кол. часов");
            SetHeadings(tbl.Cell(1, 7), "Подпись");
            int i;
            int innerCount = 1;

            for (i = 0; i < lecturerData.Rows.Count; i++)
            {
                string   s   = lecturerData.Rows[i][3].ToString();
                string[] w   = s.Split('.');
                string   res = w[1];
                if (res == curNumMonth)
                {
                    Word.Row newRow = wd.Tables[1].Rows.Add();
                    newRow.Range.Font.Bold = 0;
                    newRow.Range.ParagraphFormat.Alignment = Word.WdParagraphAlignment.wdAlignParagraphLeft;
                    newRow.Cells[1].Range.Text             = innerCount.ToString();
                    tbl.Columns[1].SetWidth(27, Word.WdRulerStyle.wdAdjustSameWidth);
                    newRow.Cells[2].Range.Text = lecturerData.Rows[i][1].ToString();
                    tbl.Columns[2].SetWidth(170, Word.WdRulerStyle.wdAdjustSameWidth);
                    string typeOfLesson = lecturerData.Rows[i][2].ToString();
                    if (typeOfLesson == "Управляемая самостоятельная работа")
                    {
                        newRow.Cells[3].Range.Text = "УСР";
                    }
                    else if (typeOfLesson == "Лабораторная работа")
                    {
                        newRow.Cells[3].Range.Text = "Лаб";
                    }
                    else
                    {
                        newRow.Cells[3].Range.Text = lecturerData.Rows[i][2].ToString();
                    }
                    tbl.Columns[3].SetWidth(60, Word.WdRulerStyle.wdAdjustSameWidth);
                    newRow.Cells[4].Range.Text = lecturerData.Rows[i][3].ToString();
                    tbl.Columns[4].SetWidth(65, Word.WdRulerStyle.wdAdjustSameWidth);
                    newRow.Cells[5].Range.Text = lecturerData.Rows[i][4].ToString();
                    tbl.Columns[5].SetWidth(44, Word.WdRulerStyle.wdAdjustSameWidth);
                    newRow.Cells[6].Range.Text = lecturerData.Rows[i][5].ToString();
                    tbl.Columns[6].SetWidth(40, Word.WdRulerStyle.wdAdjustSameWidth);
                    newRow.Cells[7].Range.Text = lecturerData.Rows[i][6].ToString();
                    tbl.Columns[7].SetWidth(60, Word.WdRulerStyle.wdAdjustSameWidth);
                    innerCount++;
                }
            }
            //i++;
            //wd.Tables[1].Rows.Add();
            //tbl.Rows[i].Cells[0].Merge(tbl.Rows[i].Cells[2]);
        }
Exemplo n.º 42
0
        //Method to generate an report of the approved hours per employee
        public void GenerateApprovedHours()
        {
            employeeList = dal.GetAllData();

            //Create an instance for word app
            Microsoft.Office.Interop.Word.Application winword = new Microsoft.Office.Interop.Word.Application();

            //Set animation status for word application
            winword.ShowAnimation = false;

            //Set status for word application is to be visible or not.
            winword.Visible = false;

            //Create a missing variable for missing value
            object missing = System.Reflection.Missing.Value;

            //Create a new document
            Microsoft.Office.Interop.Word.Document document = winword.Documents.Add(ref missing, ref missing, ref missing, ref missing);
            var data = document.Paragraphs.Add();

            document.Content.Text = "Datum: " + DateTime.Now;

            //Add header into the document
            foreach (Microsoft.Office.Interop.Word.Section section in document.Sections)
            {
                //Get the header range and add the header details.
                Microsoft.Office.Interop.Word.Range headerRange = section.Headers[Microsoft.Office.Interop.Word.WdHeaderFooterIndex.wdHeaderFooterPrimary].Range;
                headerRange.Fields.Add(headerRange, Microsoft.Office.Interop.Word.WdFieldType.wdFieldPage);
                headerRange.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
                headerRange.Font.ColorIndex           = Microsoft.Office.Interop.Word.WdColorIndex.wdBlue;
                headerRange.Font.Size = 18;
                headerRange.Text      = "URS ~ Rapportage gewerkte uren per medewerker";
            }

            //Add footer into the document
            foreach (Microsoft.Office.Interop.Word.Section wordSection in document.Sections)
            {
                //Get the footer range and add the footer details.
                Microsoft.Office.Interop.Word.Range footerRange = wordSection.Footers[Microsoft.Office.Interop.Word.WdHeaderFooterIndex.wdHeaderFooterPrimary].Range;
                footerRange.Font.ColorIndex           = Microsoft.Office.Interop.Word.WdColorIndex.wdDarkRed;
                footerRange.Font.Size                 = 10;
                footerRange.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
                footerRange.Text = "Deze rapportage wordt u aangeboden door het URS-systeem van WeShare. De gegevens in deze rapportage zijn gebaseerd op de beschikbare gegevens van het URS-systeem";
            }

            var logo  = document.Paragraphs.Add();
            var shape = document.Application.Selection.InlineShapes.AddPicture(@"D:\URS\Resources\calendar.png");

            shape.Height = 100;
            shape.Width  = 100;

            //Fill table with data from database from DAL
            int cell            = 1;
            int numberOfRecords = 0;

            foreach (Employee employee in employeeList)
            {
                numberOfRecords += employee.Hours.Count();
            }

            //Get data from the database
            var       table      = document.Paragraphs.Add();
            Paragraph para       = document.Content.Paragraphs.Add(ref missing);
            Table     firstTable = document.Tables.Add(para.Range, numberOfRecords + 1, 7, ref missing, ref missing);

            firstTable.Borders.Enable = 1;

            firstTable.Cell(1, 1).Range.Text = "Mede-werker";
            firstTable.Cell(1, 2).Range.Text = "Activiteit-ID";
            firstTable.Cell(1, 3).Range.Text = "Datum";
            firstTable.Cell(1, 4).Range.Text = "Aantal-uren";
            firstTable.Cell(1, 5).Range.Text = "Goed-gekeurd";
            firstTable.Cell(1, 6).Range.Text = "Uurtarief";
            firstTable.Cell(1, 7).Range.Text = "Uitbetalen";

            foreach (Employee employee in employeeList)
            {
                foreach (Hour hour in employee.Hours)
                {
                    cell += 1;
                    float salary = employee.salary * hour.duration;

                    firstTable.Cell(cell, 1).Range.Text = employee.firstName + "- " + employee.lastName;
                    firstTable.Cell(cell, 2).Range.Text = hour.activityID.ToString();
                    firstTable.Cell(cell, 3).Range.Text = hour.date;
                    firstTable.Cell(cell, 4).Range.Text = hour.duration.ToString();
                    firstTable.Cell(cell, 5).Range.Text = hour.approved;
                    firstTable.Cell(cell, 6).Range.Text = employee.salary.ToString();
                    firstTable.Cell(cell, 7).Range.Text = salary.ToString();
                }
            }

            winword.Visible       = true;
            winword.ShowAnimation = true;
        }
Exemplo n.º 43
0
        public void XuatRaFileWord(DataGridView DGV, string filename)
        {
            if (DGV.Rows.Count != 0)
            {
                int RowCount    = DGV.Rows.Count;
                int ColumnCount = DGV.Columns.Count;
                Object[,] DataArray = new object[RowCount + 1, ColumnCount + 1];

                //add rows
                int r = 0;
                for (int c = 0; c <= ColumnCount - 1; c++)
                {
                    for (r = 0; r <= RowCount - 1; r++)
                    {
                        DataArray[r, c] = DGV.Rows[r].Cells[c].Value;
                    } //end row loop
                }     //end column loop

                Word.Document oDoc = new Word.Document();
                oDoc.Application.Visible = true;

                //page orintation
                oDoc.PageSetup.Orientation = Word.WdOrientation.wdOrientLandscape;


                dynamic oRange = oDoc.Content.Application.Selection.Range;
                string  oTemp  = "";
                for (r = 0; r <= RowCount - 1; r++)
                {
                    for (int c = 0; c <= ColumnCount - 1; c++)
                    {
                        oTemp = oTemp + DataArray[r, c] + "\t";
                    }
                }

                //table format
                oRange.Text = oTemp;

                object Separator       = Word.WdTableFieldSeparator.wdSeparateByTabs;
                object ApplyBorders    = true;
                object AutoFit         = true;
                object AutoFitBehavior = Word.WdAutoFitBehavior.wdAutoFitContent;

                oRange.ConvertToTable(ref Separator, ref RowCount, ref ColumnCount,
                                      Type.Missing, Type.Missing, ref ApplyBorders,
                                      Type.Missing, Type.Missing, Type.Missing,
                                      Type.Missing, Type.Missing, Type.Missing,
                                      Type.Missing, ref AutoFit, ref AutoFitBehavior, Type.Missing);

                oRange.Select();

                oDoc.Application.Selection.Tables[1].Select();
                oDoc.Application.Selection.Tables[1].Rows.AllowBreakAcrossPages = 0;
                oDoc.Application.Selection.Tables[1].Rows.Alignment             = 0;
                oDoc.Application.Selection.Tables[1].Rows[1].Select();
                oDoc.Application.Selection.InsertRowsAbove(1);
                oDoc.Application.Selection.Tables[1].Rows[1].Select();

                //header row style
                oDoc.Application.Selection.Tables[1].Rows[1].Range.Bold      = 1;
                oDoc.Application.Selection.Tables[1].Rows[1].Range.Font.Name = "Tahoma";
                oDoc.Application.Selection.Tables[1].Rows[1].Range.Font.Size = 14;

                //add header row manually
                for (int c = 0; c <= ColumnCount - 1; c++)
                {
                    oDoc.Application.Selection.Tables[1].Cell(1, c + 1).Range.Text = DGV.Columns[c].HeaderText;
                }

                //table style
                oDoc.Application.Selection.Tables[1].set_Style("Table Grid 3");
                oDoc.Application.Selection.Tables[1].Rows[1].Select();
                oDoc.Application.Selection.Cells.VerticalAlignment = Word.WdCellVerticalAlignment.wdCellAlignVerticalCenter;

                //header text
                foreach (Word.Section section in oDoc.Application.ActiveDocument.Sections)
                {
                    Word.Range headerRange = section.Headers[Word.WdHeaderFooterIndex.wdHeaderFooterPrimary].Range;
                    headerRange.Fields.Add(headerRange, Word.WdFieldType.wdFieldPage);
                    headerRange.Text      = "Menu";
                    headerRange.Font.Size = 16;
                    headerRange.Font.Bold = 1;
                    headerRange.ParagraphFormat.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;
                }

                //save the file
                oDoc.SaveAs(filename);
            }
        }
Exemplo n.º 44
0
        //Method to generate an report of the occupancyrate
        public void GenerateOccupancyRate()
        {
            employeeList = dal.GetAllData();

            //Create an instance for word app
            Microsoft.Office.Interop.Word.Application winword = new Microsoft.Office.Interop.Word.Application();

            //Set animation status for word application
            winword.ShowAnimation = false;

            //Set status for word application is to be visible or not.
            winword.Visible = false;

            //Create a missing variable for missing value
            object missing = System.Reflection.Missing.Value;

            //Create a new document
            Microsoft.Office.Interop.Word.Document document = winword.Documents.Add(ref missing, ref missing, ref missing, ref missing);
            var data = document.Paragraphs.Add();

            document.Content.Text = "Datum: " + DateTime.Now;

            //Add header into the document
            foreach (Microsoft.Office.Interop.Word.Section section in document.Sections)
            {
                //Get the header range and add the header details.
                Microsoft.Office.Interop.Word.Range headerRange = section.Headers[Microsoft.Office.Interop.Word.WdHeaderFooterIndex.wdHeaderFooterPrimary].Range;
                headerRange.Fields.Add(headerRange, Microsoft.Office.Interop.Word.WdFieldType.wdFieldPage);
                headerRange.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
                headerRange.Font.ColorIndex           = Microsoft.Office.Interop.Word.WdColorIndex.wdBlue;
                headerRange.Font.Size = 18;
                headerRange.Text      = "URS ~ Rapportage bezettingsgraad";
            }

            //Add footer into the document
            foreach (Microsoft.Office.Interop.Word.Section wordSection in document.Sections)
            {
                //Get the footer range and add the footer details.
                Microsoft.Office.Interop.Word.Range footerRange = wordSection.Footers[Microsoft.Office.Interop.Word.WdHeaderFooterIndex.wdHeaderFooterPrimary].Range;
                footerRange.Font.ColorIndex           = Microsoft.Office.Interop.Word.WdColorIndex.wdDarkRed;
                footerRange.Font.Size                 = 10;
                footerRange.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
                footerRange.Text = "Deze rapportage wordt u aangeboden door het URS-systeem van WeShare. De gegevens in deze rapportage zijn gebaseerd op de beschikbare gegevens van het URS-systeem";
            }

            var logo  = document.Paragraphs.Add();
            var shape = document.Application.Selection.InlineShapes.AddPicture(@"D:\URS\Resources\calendar.png");

            shape.Height = 100;
            shape.Width  = 100;

            //Create a table into the document in a new paragraph
            //Fill table with data from database from DAL
            var       table      = document.Paragraphs.Add();
            int       number     = employeeList.Count();
            Paragraph para       = document.Content.Paragraphs.Add(ref missing);
            Table     firstTable = document.Tables.Add(para.Range, number + 1, 5, ref missing, ref missing);

            float hoursWorked = 0;
            int   cell        = 1;

            firstTable.Borders.Enable        = 1;
            firstTable.Cell(1, 1).Range.Text = "Voornaam";
            firstTable.Cell(1, 2).Range.Text = "Achternaam";
            firstTable.Cell(1, 3).Range.Text = "Contracturen";
            firstTable.Cell(1, 4).Range.Text = "Gewerkte uren";
            firstTable.Cell(1, 5).Range.Text = "Bezettingsgraad";

            //Get data from database
            foreach (Employee employee in employeeList)
            {
                cell += 1;
                firstTable.Cell(cell, 1).Range.Text = employee.firstName.ToString();
                firstTable.Cell(cell, 2).Range.Text = employee.lastName.ToString();
                firstTable.Cell(cell, 3).Range.Text = employee.contractHours.ToString();
                foreach (Hour hour in employee.Hours)
                {
                    hoursWorked += hour.duration;
                    firstTable.Cell(cell, 4).Range.Text = hoursWorked.ToString();
                    float occupancyRate = hoursWorked / float.Parse(employee.contractHours.ToString()) * 100;
                    firstTable.Cell(cell, 5).Range.Text = occupancyRate.ToString();
                }
                hoursWorked = 0;
            }

            //Make document visible
            winword.Visible       = true;
            winword.ShowAnimation = true;
        }
Exemplo n.º 45
0
 public void Init()
 {
     Word.Range range = WordApp.Selection.Range;
     WordApp.ActiveWindow.GetPoint(out cjjleft, out cjjtop, out cjjwidth, out cjjheight, range);
     this.Location = new Point(cjjleft, cjjtop + 30);
 }
Exemplo n.º 46
0
 protected abstract ITextMapping GetMappingForRange(Word.Range chunk);
Exemplo n.º 47
0
 private int check_Kernel(List<OfficeElement> ls)
 {
     int points = 0, i;
     int curPart = -1;            //当前正在分析哪一部分的考点
     for (i = 0; i < ls.Count; i++)
     {
         OfficeElement oe = ls[i];
         #region 具体考点对象定位
         if (oe.AttribName == "Root")
             continue;
         if (oe.AttribName == "Documents")
             continue;
         if (oe.AttribName == "Paragraph")
         {
             #region 段落定位
             try
             {
                 int paraIdx = int.Parse(oe.AttribValue);
                 stuPara = stuDoc.Paragraphs[paraIdx];
                 ansPara = ansDoc.Paragraphs[paraIdx];
             }
             catch
             {
                 points = 0;
                 break;
             }
             #endregion
             curPart = PART_PARAGRAPH;
             continue;
         }
         if (oe.AttribName == "Table")
         {
             #region 表格定位
             try
             {
                 int tabIdx = int.Parse(oe.AttribValue);
                 stuTab = stuDoc.Tables[tabIdx];
                 ansTab = ansDoc.Tables[tabIdx];
             }
             catch
             {
                 points = 0;
                 break;
             }
             #endregion
             curPart = PART_TABLE;
             continue;
         }
         if (oe.AttribName == "Cell")
         {
             #region 单元格定位
             try
             {
                 int rowIdx, colIdx, commaIdx;
                 commaIdx = oe.AttribValue.IndexOf(',');
                 rowIdx = int.Parse(oe.AttribValue.Substring(0, commaIdx));
                 colIdx = int.Parse(oe.AttribValue.Substring(commaIdx + 1));
                 stuCell = stuTab.Cell(rowIdx, colIdx);
                 ansCell = ansTab.Cell(rowIdx, colIdx);
             }
             catch
             {
                 points = 0;
                 break;
             }
             #endregion
             curPart = PART_CELL;
             continue;
         }
         if (oe.AttribName == "Textbox")
         {
             #region 文本框定位
             try
             {
                 int tbIdx = int.Parse(oe.AttribValue);
                 object ob = tbIdx;
                 stuSp = stuDoc.Shapes.get_Item(ref ob);
                 ansSp = ansDoc.Shapes.get_Item(ref ob);
                 stuTf = stuSp.TextFrame;
                 ansTf = ansSp.TextFrame;
             }
             catch
             {
                 points = 0;
                 break;
             }
             #endregion
             curPart = PART_TEXTBOX;
             continue;
         }
         if (oe.AttribName == "PageSetup")
         {
             #region 页面设置定位
             try
             {
                 stuPs = stuDoc.PageSetup;
                 ansPs = ansDoc.PageSetup;
             }
             catch
             {
                 points = 0;
                 break;
             }
             #endregion
             continue;
         }
         #endregion
         #region 段落属性判分
         if (curPart == PART_PARAGRAPH)
         {
             switch (oe.AttribName)
             {
                 case "Indent":
                     break;
                 case "Font":
                     stuRange = stuPara.Range;
                     ansRange = ansPara.Range;
                     break;
                 case "Dropcap":
                     stuDc = stuPara.DropCap;
                     ansDc = ansPara.DropCap;
                     break;
                 case "TextColumns":
                     stuTc = stuPara.Range.PageSetup.TextColumns;
                     ansTc = ansPara.Range.PageSetup.TextColumns;
                     break;
                 #region 段落部分
                 case "Alignment":
                     if (stuPara.Alignment == ansPara.Alignment)
                         points = int.Parse(oe.AttribValue);
                     break;
                 case "CharacterUnitFirstLineIndent":
                     if (stuPara.CharacterUnitFirstLineIndent == ansPara.CharacterUnitFirstLineIndent)
                         points = int.Parse(oe.AttribValue);
                     break;
                 case "CharacterUnitLeftIndent":
                     if (stuPara.CharacterUnitLeftIndent == ansPara.CharacterUnitLeftIndent)
                         points = int.Parse(oe.AttribValue);
                     break;
                 case "CharacterUnitRightIndent":
                     if (stuPara.CharacterUnitRightIndent == ansPara.CharacterUnitRightIndent)
                         points = int.Parse(oe.AttribValue);
                     break;
                 case "LineUnitBefore":
                     if (stuPara.LineUnitBefore == ansPara.LineUnitBefore)
                         points = int.Parse(oe.AttribValue);
                     break;
                 case "LineUnitAfter":
                     if (stuPara.LineUnitAfter == ansPara.LineUnitAfter)
                         points = int.Parse(oe.AttribValue);
                     break;
                 case "LineSpacingRule":
                     if (stuPara.LineSpacingRule == ansPara.LineSpacingRule)
                         points = int.Parse(oe.AttribValue);
                     break;
                 case "LineSpacing":
                     if (stuPara.LineSpacing == ansPara.LineSpacing)
                         points = int.Parse(oe.AttribValue);
                     break;
                 #endregion
                 #region 文字部分
                 case "Text":
                     if (stuRange.Text == ansRange.Text)
                         points = int.Parse(oe.AttribValue);
                     break;
                 case "FontSize":
                     if (stuRange.Font.Size == ansRange.Font.Size)
                         points = int.Parse(oe.AttribValue);
                     break;
                 case "FontName":
                     if (stuRange.Font.Name == ansRange.Font.Name)
                         points = int.Parse(oe.AttribValue);
                     break;
                 case "Bold":
                     if (stuRange.Font.Bold == ansRange.Font.Bold)
                         points = int.Parse(oe.AttribValue);
                     break;
                 case "Italic":
                     if (stuRange.Font.Italic == ansRange.Font.Italic)
                         points = int.Parse(oe.AttribValue);
                     break;
                 case "Underline":
                     if (stuRange.Font.Underline == ansRange.Font.Underline)
                         points = int.Parse(oe.AttribValue);
                     break;
                 case "UnderlineColor":
                     if (stuRange.Font.UnderlineColor == ansRange.Font.UnderlineColor)
                         points = int.Parse(oe.AttribValue);
                     break;
                 case "ForeColor":
                     if (stuRange.Font.Color == ansRange.Font.Color)
                         points = int.Parse(oe.AttribValue);
                     break;
                 case "HighLightColor":
                     if (stuRange.HighlightColorIndex == ansRange.HighlightColorIndex)
                         points = int.Parse(oe.AttribValue);
                     break;
                 case "Superscript":
                     if (stuRange.Font.Superscript == ansRange.Font.Superscript)
                         points = int.Parse(oe.AttribValue);
                     break;
                 case "Subscript":
                     if (stuRange.Font.Subscript == ansRange.Font.Subscript)
                         points = int.Parse(oe.AttribValue);
                     break;
                 case "Spacing":
                     if (stuRange.Font.Spacing == ansRange.Font.Spacing)
                         points = int.Parse(oe.AttribValue);
                     break;
                 case "Animation":
                     if (stuRange.Font.Animation == ansRange.Font.Animation)
                         points = int.Parse(oe.AttribValue);
                     break;
                 case "BackgroundPatternColor":
                     if (stuRange.Shading.BackgroundPatternColor == ansRange.Shading.BackgroundPatternColor)
                         points = int.Parse(oe.AttribValue);
                     break;
                 #endregion
                 #region 首字下沉
                 case "Position":
                     if (stuDc.Position == ansDc.Position)
                         points = int.Parse(oe.AttribValue);
                     break;
                 case "DcFontName":
                     if (stuDc.FontName == ansDc.FontName)
                         points = int.Parse(oe.AttribValue);
                     break;
                 case "LinesToDrop":
                     if (stuDc.LinesToDrop == ansDc.LinesToDrop)
                         points = int.Parse(oe.AttribValue);
                     break;
                 case "DistanceFromText":
                     if (stuDc.DistanceFromText == ansDc.DistanceFromText)
                         points = int.Parse(oe.AttribValue);
                     break;
                 #endregion
                 #region 分栏与栏宽
                 case "TextColumnsCount":
                     if (stuTc.Count == ansTc.Count)
                         points = int.Parse(oe.AttribValue);
                     break;
                 case "TextColumnsWidth":
                     if (stuTc.Width == ansTc.Width)
                         points = int.Parse(oe.AttribValue);
                     break;
                 case "TextColumnsSpacing":
                     if (stuTc.Spacing == ansTc.Spacing)
                         points = int.Parse(oe.AttribValue);
                     break;
                 case "TextColumnsLineBetween":
                     if (stuTc.LineBetween == ansTc.LineBetween)
                         points = int.Parse(oe.AttribValue);
                     break;
                 #endregion
             }
             continue;
         }
         #endregion
         #region 表格属性判分
         if (curPart == PART_TABLE)
         {
             switch (oe.AttribName)
             {
                 case "Rows":
                     if (stuTab.Rows.Count == ansTab.Rows.Count)
                         points = int.Parse(oe.AttribValue);
                     break;
                 case "Columns":
                     if (stuTab.Columns.Count == ansTab.Columns.Count)
                         points = int.Parse(oe.AttribValue);
                     break;
             }
             continue;
         }
         #endregion
         #region 单元格属性判分
         if (curPart == PART_CELL)
         {
             switch (oe.AttribName)
             {
                 case "Text":
                     if (stuCell.Range.Text == ansCell.Range.Text)
                         points = int.Parse(oe.AttribValue);
                     break;
                 case "Height":
                     if (stuCell.Height == ansCell.Height)
                         points = int.Parse(oe.AttribValue);
                     break;
                 case "Width":
                     if (stuCell.Width == ansCell.Width)
                         points = int.Parse(oe.AttribValue);
                     break;
             }
             continue;
         }
         #endregion
         #region 文本框属性判分
         if (curPart == PART_TEXTBOX)
         {
             switch (oe.AttribName)
             {
                 case "Text":
                     if (stuTf.TextRange.Text == ansTf.TextRange.Text)
                         points = int.Parse(oe.AttribValue);
                     break;
                 case "Orientation":
                     if (stuTf.Orientation == ansTf.Orientation)
                         points = int.Parse(oe.AttribValue);
                     break;
                 case "FontName":
                     if (stuTf.TextRange.Font.Name == ansTf.TextRange.Font.Name)
                         points = int.Parse(oe.AttribValue);
                     break;
                 case "FontSize":
                     if (stuTf.TextRange.Font.Size == ansTf.TextRange.Font.Size)
                         points = int.Parse(oe.AttribValue);
                     break;
                 case "ForeColor":
                     if (stuTf.TextRange.Font.Color == ansTf.TextRange.Font.Color)
                         points = int.Parse(oe.AttribValue);
                     break;
                 case "HighLightColor":
                     if (stuTf.TextRange.HighlightColorIndex == ansTf.TextRange.HighlightColorIndex)
                         points = int.Parse(oe.AttribValue);
                     break;
                 case "Spacing":
                     if (stuTf.TextRange.Font.Spacing == ansTf.TextRange.Font.Spacing)
                         points = int.Parse(oe.AttribValue);
                     break;
                 case "Alignment":
                     if (stuTf.TextRange.ParagraphFormat.Alignment == ansTf.TextRange.ParagraphFormat.Alignment)
                         points = int.Parse(oe.AttribValue);
                     break;
             }
             continue;
         }
         #endregion
         #region 页面设置属性判分
         if (curPart == PART_PAGESETUP)
         {
             switch (oe.AttribName)
             {
                 case "TopMargin":
                     if (stuPs.TopMargin == ansPs.TopMargin)
                         points = int.Parse(oe.AttribValue);
                     break;
                 case "BottomMargin":
                     if (stuPs.BottomMargin == ansPs.BottomMargin)
                         points = int.Parse(oe.AttribValue);
                     break;
                 case "LeftMargin":
                     if (stuPs.LeftMargin == ansPs.LeftMargin)
                         points = int.Parse(oe.AttribValue);
                     break;
                 case "RightMargin":
                     if (stuPs.RightMargin == ansPs.RightMargin)
                         points = int.Parse(oe.AttribValue);
                     break;
                 case "HeaderDistance":
                     if (stuPs.HeaderDistance == ansPs.HeaderDistance)
                         points = int.Parse(oe.AttribValue);
                     break;
                 case "FooterDistance":
                     if (stuPs.FooterDistance == ansPs.FooterDistance)
                         points = int.Parse(oe.AttribValue);
                     break;
                 case "Orientation":
                     if (stuPs.Orientation == ansPs.Orientation)
                         points = int.Parse(oe.AttribValue);
                     break;
                 case "GutterPos":
                     if (stuPs.GutterPos == ansPs.GutterPos)
                         points = int.Parse(oe.AttribValue);
                     break;
             }
             continue;
         }
         #endregion
     }
     return points;
 }
Exemplo n.º 48
0
        /// <summary>
        /// Event triggered when the active document changes.
        /// <remarks>This event is triggered every time you switch to a different document window.
        /// It does NOT refer to content changing.</remarks>
        /// </summary>
        void Application_DocumentChange()
        {
            //Remove the orphan task panes.
            RemoveOrphans();
            //Reassign values to the document and wiki page states.
            lastActiveDocument = ActiveDocumentInstance;
            lastActiveDocumentFullName = ActiveDocumentFullName;
            activeDocumentContent = ActiveDocumentContentRange;
            //if current document is a wiki page.
            if (EditedPages.ContainsKey(lastActiveDocumentFullName))
            {
                currentPageFullName = EditedPages[lastActiveDocumentFullName];
            }
            else
            {
                currentPageFullName = null;
            }
            //Update the toggle button.
            UpdateWikiExplorerButtonState();

            //Trigger event
            DocumentChanged();
        }