private void btnPrintWord_Click(object sender, RoutedEventArgs e)
        {
            int number = 0;
            string fileName = "Test";
            var doc = DocX.Create(fileName);
            doc.InsertParagraph("Test");
            for (int i = 0; i <= myProductinKars.Count(); i++)
            {
                number++;
            }
            MessageBox.Show(number.ToString());
            Xceed.Document.NET.Table table = doc.AddTable(number, 4);
            table.Alignment = Alignment.center;
            table.Design = TableDesign.ColorfulList;

            table.Rows[0].Cells[0].Paragraphs.First().Append("Product");
            table.Rows[0].Cells[1].Paragraphs.First().Append("Quantity");
            table.Rows[0].Cells[2].Paragraphs.First().Append("BTW");
            table.Rows[0].Cells[3].Paragraphs.First().Append("Price");
            for (int i = 0; i < myProductinKars.Count(); i++)
            {
                table.Rows[i + 1].Cells[0].Paragraphs.First().Append(myProductinKars[i].ProductInKarNaam);
                table.Rows[i + 1].Cells[1].Paragraphs.First().Append(myProductinKars[i].Quantity.ToString() + " " + myProductinKars[i].Unit);
                table.Rows[i + 1].Cells[2].Paragraphs.First().Append(myProductinKars[i].Btw.ToString() + "%");
                table.Rows[i + 1].Cells[3].Paragraphs.First().Append((myProductinKars[i].Price * myProductinKars[i].Quantity).ToString() + "€");
            }
            doc.InsertTable(table);


            doc.Save();
        }
        private void btkKilometri_Click(object sender, EventArgs e)
        {
            List <Sport> sport = new List <Sport>();

            sport = Info();
            //Location Path
            string fileName = @"Info.docx";

            var doc = DocX.Create(fileName);
            //Formatting Title
            Formatting titleFormat = new Formatting();

            //Specify font family
            titleFormat.FontFamily = new Font("Batang");
            //Specify font size
            titleFormat.Size           = 18;
            titleFormat.Position       = 40;
            titleFormat.FontColor      = System.Drawing.Color.Orange;
            titleFormat.UnderlineColor = System.Drawing.Color.Gray;
            titleFormat.Italic         = true;
            //Formatting Text Paragraph
            Formatting textParagraphFormat = new Formatting();

            //font family
            textParagraphFormat.FontFamily = new Font("Century Gothic");
            //font size
            textParagraphFormat.Size = 10;
            //Spaces between characters
            textParagraphFormat.Spacing = 2;

            int count = sport.Count;
            //Create Table with 2 rows and 4 columns.
            Table t = doc.AddTable(count + 3, 4);

            t.Alignment = Alignment.center;
            t.Design    = TableDesign.ColorfulList;
            //Fill cells by adding text.
            t.Rows[0].Cells[0].Paragraphs.First().Append("Kolesar");
            t.Rows[0].Cells[1].Paragraphs.First().Append("Total distance");
            t.Rows[0].Cells[2].Paragraphs.First().Append("Total calories");
            t.Rows[0].Cells[3].Paragraphs.First().Append("Total time");

            int stevec = 1;

            foreach (var item in sport)
            {
                t.Rows[stevec].Cells[0].Paragraphs.First().Append(stevec.ToString());
                t.Rows[stevec].Cells[1].Paragraphs.First().Append(item.Stevilo_prevozenih_km);
                t.Rows[stevec].Cells[2].Paragraphs.First().Append(item.Porabljene_kalorije);
                t.Rows[stevec].Cells[3].Paragraphs.First().Append(item.Trajanje_aktivnosti);
                stevec++;
            }

            doc.InsertTable(t);
            doc.Save();
            Process.Start("WINWORD.EXE", fileName);
        }
示例#3
0
 public void OpenTask(Exam exam, Ticket ticket, bool markAnswers)
 {
     CloseWord();
     OneAnswerQuestion[] questions = ticket.GetQuestions().Cast <OneAnswerQuestion>().ToArray();
     using (DocX docXdocument = DocX.Create(path.ToString()))
     {
         int i, j;
         docXdocument.AddFooters();
         docXdocument.SetDefaultFont(new Xceed.Document.NET.Font("Times New Roman"));
         Xceed.Document.NET.Paragraph headerParagraph = docXdocument.InsertParagraph();
         Xceed.Document.NET.Paragraph paragraph       = docXdocument.InsertParagraph();
         headerParagraph.Append($"Перегляд завдання")
         .Bold()
         .FontSize(28);
         paragraph.Append($"Завдання білету \"{ticket.TicketName}\":")
         .FontSize(24);
         Xceed.Document.NET.Table table = docXdocument.AddTable(questions.Length, 2);
         table.SetWidthsPercentage(new[] { 50f, 50 }, docXdocument.PageWidth - docXdocument.PageWidth / 5);
         table.SetBorder(TableBorderType.Bottom, new Xceed.Document.NET.Border(BorderStyle.Tcbs_double, BorderSize.two, 0, Color.Black));
         table.SetBorder(TableBorderType.Top, new Xceed.Document.NET.Border(BorderStyle.Tcbs_double, BorderSize.two, 0, Color.Black));
         table.SetBorder(TableBorderType.Left, new Xceed.Document.NET.Border(BorderStyle.Tcbs_double, BorderSize.two, 0, Color.Black));
         table.SetBorder(TableBorderType.Right, new Xceed.Document.NET.Border(BorderStyle.Tcbs_double, BorderSize.two, 0, Color.Black));
         table.SetBorder(TableBorderType.InsideV, new Xceed.Document.NET.Border(BorderStyle.Tcbs_double, BorderSize.two, 0, Color.Black));
         for (i = 0; i < questions.Length; i++)
         {
             table.Rows[i].Cells[0]
             .InsertParagraph()
             .Append($"{questions[i].QuestionNumber + exam.FirstQuestionNumber}) {questions[i].QuestionContent.Text}")
             .FontSize(12);
             Xceed.Document.NET.Paragraph tableParagraph = table.Rows[i].Cells[1].InsertParagraph();
             for (j = 0; j < questions[i].QuestionContent.Answers.Count; j++)
             {
                 Xceed.Document.NET.Paragraph tempParagraph = tableParagraph.Append($"{(j < questions[i].QuestionContent.Letters.Length ? questions[i].QuestionContent.Letters[j].ToString() : "*")}{questions[i].QuestionContent.Devider} { questions[i].QuestionContent.Answers[j]};{Environment.NewLine}");
                 if (markAnswers && questions[i].Answer.Content == questions[i].QuestionContent.Answers[j])
                 {
                     tempParagraph.Bold()
                     .FontSize(12);
                 }
             }
         }
         docXdocument.InsertTable(table);
         docXdocument.Footers.Odd.InsertParagraph()
         .Append("Створено за допомогою SimplEx Program")
         .FontSize(10)
         .UnderlineStyle(UnderlineStyle.singleLine)
         .Alignment = Alignment.right;
         docXdocument.Save();
     }
     OpenWord();
 }
示例#4
0
        public static void SetColumnWidth(Table t, int[] ColSizePercents, float pagesize)
        {
            /* Table t = document.AddTable(rows,columns); */
            var columnsizes = new float[ColSizePercents.Length];

            t.AutoFit = AutoFit.ColumnWidth;
            for (int x = 0; x < t.ColumnCount; x++)
            {
                //t.SetColumnWidth(x, columnsizes[x]);
                columnsizes[x] = pagesize * ColSizePercents[x] / 100;
                for (int y = 0; y < t.RowCount; y++)
                {
                    t.Rows[y].Cells[x].Width = columnsizes[x];
                }
            }
        }
示例#5
0
        private async Task CreateWorkingExperiences(DocX doc, long userId)
        {
            var workingExperiences = await _myProfileAppService.GetUserWorkingExperience(userId);

            int    stt          = 1;
            string Headingtitle = "WORKING EXPERIENCES";

            var p = doc.InsertParagraph(Headingtitle);

            p.StyleName = "Heading1";
            p.FontSize(12);
            p.Font("Times new roman");
            foreach (var item in workingExperiences)
            {
                var projectName = doc.InsertParagraph();
                projectName.StyleName = "Heading3";
                projectName.Append($"{stt.ConvertIntToRoman()}.{GetSpacingString(5)}{item.ProjectName}");
                projectName.Bold(false);
                projectName.FontSize(11);
                projectName.Font("Times new roman");
                projectName.SpacingAfter(5);

                // Check time in current project
                var endTime = item.EndTime != null?item.EndTime.Value.ToString("MMMM yyyy", new System.Globalization.CultureInfo("en-US")) : "Now";

                Xceed.Document.NET.Table table = doc.AddTable(5, 2);
                table.SetColumnWidth(0, 130d);
                table.SetColumnWidth(1, 325d);

                table.Rows[0].Cells[0].Paragraphs.First().Append("Duration").FontSize(12).Bold();
                table.Rows[1].Cells[0].Paragraphs.First().Append("Position").FontSize(12).Bold();
                table.Rows[2].Cells[0].Paragraphs.First().Append("Project Description").FontSize(12).Bold();
                table.Rows[3].Cells[0].Paragraphs.First().Append("My responsibilities").FontSize(12).Bold();
                table.Rows[4].Cells[0].Paragraphs.First().Append("Technologies").FontSize(12).Bold();

                table.Rows[0].Cells[1].Paragraphs.First().Append($"{item.StartTime.Value.ToString("MMMM yyyy", new System.Globalization.CultureInfo("en-US"))} - {endTime}").FontSize(12);
                table.Rows[1].Cells[1].Paragraphs.First().Culture(new System.Globalization.CultureInfo("en-US")).Append($"{item.Position}").FontSize(12);
                table.Rows[2].Cells[1].Paragraphs.First().Culture(new System.Globalization.CultureInfo("en-US")).Append($"{item.ProjectDescription}").FontSize(12);
                table.Rows[3].Cells[1].Paragraphs.First().Culture(new System.Globalization.CultureInfo("en-US")).Append($"{item.Responsibility}").FontSize(12);
                table.Rows[4].Cells[1].Paragraphs.First().Culture(new System.Globalization.CultureInfo("en-US")).Append($"{item.Technologies}").FontSize(12);
                projectName.InsertTableAfterSelf(table);
                stt++;
            }
        }
示例#6
0
        }///////////Создание файла и запись информации о клиентах

        private void WriteService(string fileName)
        {
            int checkedRowsCount = 0;

            for (int i = 0; i < data.RowCount; i++)
            {
                if (Convert.ToBoolean(data[checkBoxColumnIndex, i].Value))
                {
                    checkedRowsCount++;
                }
            }
            DocX doc = DocX.Create(fileName);

            Paragraph paragraph = doc.InsertParagraph();

            paragraph.Alignment = Alignment.right;
            paragraph.AppendLine("ElecPair").Font("Arial Black").FontSize(16).UnderlineStyle(UnderlineStyle.singleLine).Highlight(Highlight.magenta);
            paragraph.AppendLine($"(29) 970 - 14 - 80\r\[email protected]").Font("Arial Black").FontSize(12);
            Table table = doc.AddTable(checkedRowsCount + 1, 3);

            table.Design = TableDesign.TableGrid;

            table.Rows[0].Cells[0].Paragraphs[0].Append("Тип оборудования").Font("Arial").Bold();
            table.Rows[0].Cells[1].Paragraphs[0].Append("Вид работ").Font("Arial").Bold();
            table.Rows[0].Cells[2].Paragraphs[0].Append("Стоимость, руб").Font("Arial").Bold();

            int index = 1;

            for (int i = 0; i < checkedRowsCount; i++)
            {
                table.Rows[index].Cells[0].Paragraphs[0].Append(data[1, i].Value.ToString()).Font("Arial");
                table.Rows[index].Cells[1].Paragraphs[0].Append(data[2, i].Value.ToString()).Font("Arial");
                table.Rows[index].Cells[2].Paragraphs[0].Append(data[3, i].Value.ToString()).Font("Arial");

                index++;
            }
            doc.InsertParagraph().InsertTableAfterSelf(table);
            doc.AddProtection(EditRestrictions.readOnly);
            doc.Save();
        }//////////Создание файла и запись информации об услугах
示例#7
0
        private void WriteClients(string fileName)
        {
            DocX doc = DocX.Create(fileName);

            for (int i = 0; i < data.RowCount; i++)
            {
                if (Convert.ToBoolean(data[checkBoxColumnIndex, i].Value))
                {
                    Paragraph paragraph = doc.InsertParagraph();
                    paragraph.Alignment = Alignment.right;
                    paragraph.AppendLine("ElecPair").Font("Arial Black").FontSize(16).UnderlineStyle(UnderlineStyle.singleLine).Highlight(Highlight.magenta);;
                    paragraph.AppendLine($"(29) 970 - 14 - 80\r\[email protected]").Font("Arial Black").FontSize(12);

                    doc.InsertParagraph($"Клиент: {data[1, i].Value}").Font("Arial Black").FontSize(14);
                    doc.InsertParagraph($"Телефон: {data[2, i].Value}").Font("Arial Black").FontSize(14);

                    doc.InsertParagraph($"Сотрудник: {userFullName}").Font("Arial Black").FontSize(14);

                    doc.InsertParagraph($"Дата принятия в ремонт: {data[3, i].Value}").Font("Arial Black").FontSize(12);

                    Table table = doc.AddTable(4, 2);
                    table.Design = TableDesign.TableGrid;

                    table.Rows[0].Cells[0].Paragraphs[0].Append("Принятое оборудование").Font("Arial").Bold();
                    table.Rows[1].Cells[0].Paragraphs[0].Append("Заявленная неисправность").Font("Arial").Bold();
                    table.Rows[2].Cells[0].Paragraphs[0].Append("Вид работ").Font("Arial").Bold();
                    table.Rows[3].Cells[0].Paragraphs[0].Append("Сумма, руб").Font("Arial").Bold();

                    table.Rows[0].Cells[1].Paragraphs[0].Append(data[5, i].Value.ToString()).Font("Arial");
                    table.Rows[1].Cells[1].Paragraphs[0].Append(data[6, i].Value.ToString()).Font("Arial");
                    table.Rows[2].Cells[1].Paragraphs[0].Append(data[7, i].Value.ToString()).Font("Arial");
                    table.Rows[3].Cells[1].Paragraphs[0].Append(data[8, i].Value.ToString()).Font("Arial");

                    doc.InsertParagraph().InsertTableAfterSelf(table);
                    doc.InsertParagraph($"Дата выдачи: {data[4, i].Value}").Font("Arial Black").FontSize(12);;
                }
            }
            doc.AddProtection(EditRestrictions.readOnly);
            doc.Save();
        }///////////Создание файла и запись информации о клиентах
        //Word Document
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            int    number     = 0;
            int    quantity   = 0;
            double totalPrice = 0;

            using (IndividueelProjectEntities2 ctx = new IndividueelProjectEntities2())
            {
                if (cmbCustomer.SelectedValue != null)
                {
                    var        cus         = ctx.Klants.Select(x => x).Where(x => x.ID == (int)cmbCustomer.SelectedValue).FirstOrDefault();
                    string     fileName    = cus.Voornaam + "_" + cus.Achternaam + "_" + loggedInUser.Username + "_" + DateTime.Now.ToString("dd_MMMM_yyyy");
                    var        doc         = DocX.Create(fileName);
                    string     title       = "Palfi Computer Warehouse";
                    Formatting titleFormat = new Formatting();
                    titleFormat.FontFamily     = new Xceed.Document.NET.Font("Times new roman");
                    titleFormat.Size           = 20D;
                    titleFormat.Position       = 40;
                    titleFormat.FontColor      = System.Drawing.Color.Blue;
                    titleFormat.UnderlineColor = System.Drawing.Color.Black;

                    string CustomerData = $"{cus.Voornaam + "" + cus.Achternaam }" + Environment.NewLine +
                                          cus.Gemeente + " " + cus.Postcode + Environment.NewLine +
                                          cus.Straatnaam + " " + cus.Huisnummer + "/" + cus.Bus + Environment.NewLine +
                                          cus.Emailadres + Environment.NewLine +
                                          cus.Telefoonnummer + Environment.NewLine +
                                          Environment.NewLine;

                    Formatting customerDataFormat = new Formatting();
                    customerDataFormat.FontFamily = new Xceed.Document.NET.Font("Century Gothic");
                    customerDataFormat.Size       = 12D;

                    Xceed.Document.NET.Paragraph paragraphTitel = doc.InsertParagraph(title, false, titleFormat);
                    paragraphTitel.Alignment = Alignment.center;

                    doc.InsertParagraph(CustomerData, false, customerDataFormat);



                    for (int i = 0; i <= myProductinKars.Count(); i++)
                    {
                        number++;
                    }
                    Xceed.Document.NET.Table table = doc.AddTable(number, 4);
                    table.Alignment = Alignment.center;
                    table.Design    = TableDesign.ColorfulList;

                    table.Rows[0].Cells[0].Paragraphs.First().Append("Product");
                    table.Rows[0].Cells[1].Paragraphs.First().Append("Quantity");
                    table.Rows[0].Cells[2].Paragraphs.First().Append("TAX");
                    table.Rows[0].Cells[3].Paragraphs.First().Append("Price");
                    for (int i = 0; i < myProductinKars.Count(); i++)
                    {
                        table.Rows[i + 1].Cells[0].Paragraphs.First().Append(myProductinKars[i].ProductInKarNaam);
                        table.Rows[i + 1].Cells[1].Paragraphs.First().Append(myProductinKars[i].Quantity.ToString() + " " + myProductinKars[i].Unit);
                        table.Rows[i + 1].Cells[2].Paragraphs.First().Append(myProductinKars[i].Btw.ToString() + "%");
                        table.Rows[i + 1].Cells[3].Paragraphs.First().Append((((myProductinKars[i].Price + myProductinKars[i].Margin1) * (1 + myProductinKars[i].Btw / 100)) * myProductinKars[i].Quantity).ToString() + "€");
                    }
                    doc.InsertTable(table);

                    Xceed.Document.NET.Table sum = doc.AddTable(1, 4);
                    sum.Alignment = Alignment.center;
                    sum.Design    = (TableDesign)TableBorderType.Bottom;


                    foreach (var item in myProductinKars)
                    {
                        totalPrice += ((item.Price + item.Margin1) * (1 + item.Btw / 100)) * item.Quantity;
                        quantity   += item.Quantity;
                    }

                    sum.Rows[0].Cells[1].Paragraphs.First().Append("Total  " + quantity.ToString());
                    sum.Rows[0].Cells[2].Paragraphs.First().Append("With TAX");
                    sum.Rows[0].Cells[3].Paragraphs.First().Append("Total price  " + totalPrice.ToString());
                    doc.InsertTable(sum);
                    doc.Save();
                }
            }
        }
        private void createExportDoc()
        {
            try
            {
                DBManager con = new DBManager();

                var modelAnimalpark = con.getAnimalparkList();

                if (extension == string.Empty)
                {
                    MessageBox.Show("Не выбран тип экспортруемого файла");
                    return;
                }


                switch (extension)
                {
                case (".docx"):
                    string pathDocumentDOCX = Session.baseDir + "Учет товар" + extension;
                    DocX   document         = DocX.Create(pathDocumentDOCX);
                    Xceed.Document.NET.Paragraph paragraph = document.InsertParagraph();
                    paragraph.
                    AppendLine("Документ '" + "Отчет о учете автомобилей" + "' создан " + DateTime.Now.ToShortDateString()).
                    Font("Time New Roman").
                    FontSize(16).Bold().Alignment = Alignment.left;

                    paragraph.AppendLine();
                    Xceed.Document.NET.Table doctable = document.AddTable(modelAnimalpark.Count + 1, 2);
                    doctable.Design       = TableDesign.TableGrid;
                    doctable.TableCaption = "учет товара";

                    doctable.Rows[0].Cells[0].Paragraphs[0].Append("Учет товара").Font("Times New Roman").FontSize(14);

                    for (int i = 0; i < modelAnimalpark.Count; i++)
                    {
                        doctable.Rows[i + 1].Cells[0].Paragraphs[0].Append(modelAnimalpark[i].Number).Font("Times New Roman").FontSize(14);
                    }
                    document.InsertParagraph().InsertTableAfterSelf(doctable);
                    document.Save();
                    MessageBox.Show("Отчет успешно сформирован!");
                    Process.Start(pathDocumentDOCX);
                    break;

                case (".xlsx"):
                    Excel.Application excel;
                    Excel.Workbook    worKbooK;
                    Excel.Worksheet   worKsheeT;
                    Excel.Range       celLrangE;

                    string pathDocumentXLSX = Session.baseDir + "Учет о животных" + extension;

                    try
                    {
                        excel               = new Excel.Application();
                        excel.Visible       = false;
                        excel.DisplayAlerts = false;
                        worKbooK            = excel.Workbooks.Add(Type.Missing);


                        worKsheeT      = (Microsoft.Office.Interop.Excel.Worksheet)worKbooK.ActiveSheet;
                        worKsheeT.Name = "Учет о животных";

                        worKsheeT.Range[worKsheeT.Cells[1, 1], worKsheeT.Cells[1, 8]].Merge();
                        worKsheeT.Cells[1, 1]     = "Учет о животных";
                        worKsheeT.Cells.Font.Size = 15;

                        for (int i = 0; i < modelAnimalpark.Count; i++)
                        {
                            worKsheeT.Cells[i + 3, 1] = modelAnimalpark[i].Number;
                        }

                        worKbooK.SaveAs(pathDocumentXLSX);;
                        worKbooK.Close();
                        excel.Quit();
                        MessageBox.Show("Отчет успешно сформирован!");
                        Process.Start(pathDocumentXLSX);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                    finally
                    {
                        worKsheeT = null;
                        celLrangE = null;
                        worKbooK  = null;
                    }

                    break;


                case (".pdf"):
                    string pathDocumentPDF = Session.baseDir + "Учет о животных" + extension;
                    if (File.Exists(Session.baseDir + "Учет о животных.docx"))
                    {
                        Word.Application appWord = new Word.Application();
                        var wordDocument         = appWord.Documents.Open(Session.baseDir + "Учет о животных.docx");
                        wordDocument.ExportAsFixedFormat(pathDocumentPDF, Word.WdExportFormat.wdExportFormatPDF);
                        MessageBox.Show("Отчет успешно сформирован!");
                        wordDocument.Close();
                        Process.Start(pathDocumentPDF);
                    }
                    else
                    {
                        MessageBox.Show("Сначала сформируйте отчет .docx");
                    }
                    break;
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Отсутсвие Ms Office на компьютере. Пожалуйста скачайте его.");
                Process.Start("https://www.microsoft.com/ru-ru/microsoft-365/compare-all-microsoft-365-products?tab=1&rtc=1");
            }
        }
示例#10
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                savePath = pathTB.Text;
                string fileName = Parsing.CheckForDuplicateDOCX(savePath, savePath, protocolNumTB.Text + " (" + MetalMarkingsTB.Text + ")");
                var    doc      = DocX.Create(fileName);



                Xceed.Document.NET.Formatting smallText = new Xceed.Document.NET.Formatting();
                smallText.FontColor  = Color.Black;
                smallText.FontFamily = new Xceed.Document.NET.Font("Times New Roman");
                smallText.Size       = 11;
                smallText.Bold       = false;
                smallText.Position   = 1;


                Xceed.Document.NET.Formatting boldSmall = new Xceed.Document.NET.Formatting();
                boldSmall.FontColor  = Color.Black;
                boldSmall.FontFamily = new Xceed.Document.NET.Font("Times New Roman");
                boldSmall.Size       = 11;
                boldSmall.Bold       = true;
                boldSmall.Position   = 1;



                doc.PageLayout.Orientation = Xceed.Document.NET.Orientation.Landscape;
                Xceed.Document.NET.Formatting bold = new Xceed.Document.NET.Formatting();
                bold.FontColor  = Color.Black;
                bold.FontFamily = new Xceed.Document.NET.Font("Times New Roman");
                bold.Size       = 12;
                bold.Bold       = true;
                bold.Position   = 1;



                Xceed.Document.NET.Formatting defaultText = new Xceed.Document.NET.Formatting();
                defaultText.FontColor  = Color.Black;
                defaultText.FontFamily = new Xceed.Document.NET.Font("Times New Roman");
                defaultText.Size       = 12;
                defaultText.Bold       = false;
                defaultText.Position   = 1;



                doc.SetDefaultFont(new Xceed.Document.NET.Font("Times New Roman"), 12, Color.Black);

                doc.InsertParagraph(protocolNumTB.Text, false, bold).Alignment    = Xceed.Document.NET.Alignment.center;
                doc.InsertParagraph(generalDateTB.Text, false, bold).Alignment    = Xceed.Document.NET.Alignment.center;
                doc.InsertParagraph(experimentsForTB.Text, false, bold).Alignment = Xceed.Document.NET.Alignment.center;
                var l1 = doc.InsertParagraph(label1.Text, false, bold);
                l1.Append(" " + experimentMethods.Text, defaultText);
                doc.InsertParagraph();
                var l2 = doc.InsertParagraph(label2.Text, false, bold);
                l2.Append(" " + applicationTB.Text, defaultText);
                var l3 = doc.InsertParagraph(label3.Text, false, bold);
                l3.Append(" " + recieveDataTB.Text, defaultText);
                doc.InsertParagraph();
                var l4 = doc.InsertParagraph(label4.Text, false, bold);
                l4.Append(" " + nameAndAdressTB.Text, defaultText);

                var l5 = doc.InsertParagraph(label5.Text, false, bold);
                l5.Append(" " + objectOfTheExperimentTB.Text, defaultText);
                var l6 = doc.InsertParagraph(label6.Text, false, bold);
                l6.Append(" " + MetalMarkingsTB.Text, defaultText);
                doc.InsertParagraph();

                var l7 = doc.InsertParagraph(label7.Text, false, bold);

                Xceed.Document.NET.Table infoData = doc.AddTable(informationData.Rows.Count, 4);


                infoData.Rows[0].Cells[0].InsertParagraph("Объекты испытаний", false, bold);
                infoData.Rows[0].Cells[0].Width += 30;
                infoData.Rows[0].Cells[1].InsertParagraph("Маркировка", false, bold);
                infoData.Rows[0].Cells[2].InsertParagraph("Марка стали", false, bold);
                infoData.Rows[0].Cells[3].InsertParagraph("Сортамент, мм", false, bold);

                for (int i = 0; i < informationData.Rows.Count - 1; i++)
                {
                    if (informationData.Rows[i].Cells[0].Value == null || informationData.Rows[i].Cells[1].Value == null || informationData.Rows[i].Cells[2].Value == null || informationData.Rows[i].Cells[3].Value == null)
                    {
                        MessageBox.Show("Проверьте что все значения в ячейках заполнены. (кроме последней строки) Для того чтоб заполнить ячейку после ввода нажмите Enter");
                    }
                    else
                    {
                        infoData.Rows[i].Cells[0].InsertParagraph(informationData.Rows[i + 1].Cells[0].Value.ToString(), false, defaultText);
                        infoData.Rows[i].Cells[1].InsertParagraph(informationData.Rows[i + 1].Cells[1].Value.ToString(), false, defaultText).Alignment = Xceed.Document.NET.Alignment.center;
                        infoData.Rows[i].Cells[2].InsertParagraph(informationData.Rows[i + 1].Cells[2].Value.ToString(), false, defaultText).Alignment = Xceed.Document.NET.Alignment.center;
                        infoData.Rows[i].Cells[3].InsertParagraph(informationData.Rows[i + 1].Cells[3].Value.ToString(), false, defaultText).Alignment = Xceed.Document.NET.Alignment.center;
                    }
                }


                doc.InsertTable(infoData);
                doc.InsertParagraph();

                var l8 = doc.InsertParagraph(label8.Text, false, bold);
                l8.Append(" " + experimentDateTB.Text, defaultText);
                doc.InsertSectionPageBreak();
                doc.InsertParagraph();
                var l9 = doc.InsertParagraph(label9.Text, false, bold);


                Xceed.Document.NET.Table deviceInfo = doc.AddTable(1, 1);
                deviceInfo.Rows[0].Cells[0].InsertParagraph(deviceInfoTB.Text, false, defaultText);
                deviceInfo.Rows[0].Cells[0].Width = doc.PageWidth;
                doc.InsertTable(deviceInfo);
                doc.InsertParagraph();

                var l10 = doc.InsertParagraph(label10.Text, false, bold);
                doc.InsertParagraph("\t" + temperatureTB.Text, false, defaultText);
                doc.InsertParagraph("\t" + musicalTB.Text, false, defaultText);

                doc.InsertSectionPageBreak();
                var l13 = doc.InsertParagraph(label11.Text, false, bold);
                if (squareMetalSamplesTable.Rows.Count > 1)
                {
                    Xceed.Document.NET.Table squareMetalSamplesTableData = doc.AddTable(squareMetalSamplesTable.Rows.Count, squareMetalSamplesTable.Columns.Count - 1);


                    for (int i = 0; i < squareMetalSamplesTable.RowCount; i++)
                    {
                        for (int j = 0; j < squareMetalSamplesTable.Columns.Count - 1; j++)
                        {
                            if (i == 0)
                            {
                                string tempStr = squareMetalSamplesTable.Columns[j].HeaderText;


                                squareMetalSamplesTableData.Rows[i].Cells[j].InsertParagraph(tempStr, false, boldSmall);
                            }
                            else
                            {
                                squareMetalSamplesTableData.Rows[i].Cells[j].InsertParagraph(squareMetalSamplesTable.Rows[i - 1].Cells[j].Value.ToString(), false, smallText);
                            }
                        }
                    }
                    doc.InsertTable(squareMetalSamplesTableData);
                    doc.InsertSectionPageBreak();
                }
                if (roundMetalSamplesTable.Rows.Count > 1)
                {
                    Xceed.Document.NET.Table roundMetalSamplesTableData = doc.AddTable(roundMetalSamplesTable.Rows.Count, roundMetalSamplesTable.Columns.Count);


                    for (int i = 0; i < roundMetalSamplesTable.RowCount; i++)
                    {
                        for (int j = 0; j < roundMetalSamplesTable.Columns.Count; j++)
                        {
                            if (i == 0)
                            {
                                string tempStr = roundMetalSamplesTable.Columns[j].HeaderText;


                                roundMetalSamplesTableData.Rows[i].Cells[j].InsertParagraph(tempStr, false, boldSmall);
                            }
                            else
                            {
                                roundMetalSamplesTableData.Rows[i].Cells[j].InsertParagraph(roundMetalSamplesTable.Rows[i - 1].Cells[j].Value.ToString(), false, smallText);
                            }
                        }
                    }
                    doc.InsertTable(roundMetalSamplesTableData);
                }



                doc.AddHeaders();
                doc.DifferentFirstPage = true;
                boldSmall.Size         = 10;
                smallText.Size         = 10;


                var headerDefault = doc.Headers.Odd;



                Bitmap bmp     = new Bitmap(ComPortReader.Properties.Resources.ИТ_Сервис);
                var    image   = doc.AddImage(GetResourceStream(@"ИТ_Сервис"));
                var    picture = image.CreatePicture(196 / 3, 401 / 3);

                var image2   = doc.AddImage(GetResourceStream(@"Визитка"));
                var picture2 = image2.CreatePicture(261 / 3, 818 / 3);

                //var headerFirstParagraph = doc.Headers.First.InsertParagraph();
                //headerFirstParagraph.InsertPicture(picture);
                //headerFirstParagraph.InsertParagraphBeforeSelf(doc.InsertParagraph());


                var       headerDefault1 = doc.Headers.First;
                Paragraph hp             = headerDefault1.Paragraphs.First();
                hp.InsertPicture(picture, 0);
                hp.Append("                                                                                                 ");
                hp.AppendPicture(picture2);


                doc.Headers.First.InsertParagraph("Испытательный центр", false, boldSmall).Alignment = Xceed.Document.NET.Alignment.center;
                doc.Headers.First.InsertParagraph("443036, г.Самара, Железнодорожный Район, Набережная реки Самара, дом 1", false, smallText).Alignment = Xceed.Document.NET.Alignment.center;
                doc.Headers.First.InsertParagraph("______________________________________________________________________________________________________________________");

                doc.DifferentOddAndEvenPages = false;
                doc.AddFooters();


                Paragraph tempParagraph1 = doc.Footers.First.InsertParagraph(" из ");
                tempParagraph1.Append("").InsertPageCount(PageNumberFormat.normal, 4);
                tempParagraph1.Append("").InsertPageNumber(PageNumberFormat.normal, 0);

                Paragraph tempParagraph2 = doc.Footers.Odd.InsertParagraph(" из ");
                tempParagraph2.Append("").InsertPageCount(PageNumberFormat.normal, 4);
                tempParagraph2.Append("").InsertPageNumber(PageNumberFormat.normal, 0);
                //tempParagraph.AppendLine(" из ").InsertPageCount(PageNumberFormat.normal, 6);

                string info = this.protocolNumTB.Text + " " + generalDateTB.Text;
                doc.Footers.First.InsertParagraph(info);
                doc.Footers.First.InsertParagraph("Не может быть частично и полностью воспроизведен без письменного разрешения испытательного центра");

                doc.Footers.Odd.InsertParagraph(info);
                doc.Footers.Odd.InsertParagraph("Не может быть частично и полностью воспроизведен без письменного разрешения испытательного центра");


                doc.Save();

                try
                {
                    System.Diagnostics.Process.Start(fileName);
                }
                catch (Exception ex1)
                { MessageBox.Show(ex1.ToString()); }
            }
            catch (Exception ex)
            {
                if (ex is System.IO.DirectoryNotFoundException)
                {
                    MessageBox.Show("Неверный путь: " + ex.Message);
                }
                else
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }
示例#11
0
        private void CreateOrder(int course, string code, string direct)
        {
            string file = "order.docx";
            // создаём документ
            DocX document = DocX.Create(dir + file);

            document.SetDefaultFont(new Font("Times New Roman"), fontSize: 12); // Устанавливаем стандартный для документа шрифт и размер шрифта
            document.MarginLeft   = 42.5f;
            document.MarginTop    = 34.1f;
            document.MarginRight  = 34.1f;
            document.MarginBottom = 34.1f;

            document.InsertParagraph($"Проект приказа\n\n").Bold().Alignment = Alignment.center;
            document.InsertParagraph($"\tВ соответствии с календарным графиком учебного процесса допустить " +
                                     $"и направить для прохождения {form_pract.SelectedItem.ToString().ToLower()} практики {combobox_type.SelectedItem} " +
                                     $"следующих студентов {course} курса, очной формы, направление подготовки {code} «{direct}», " +
                                     $"профиль «Прикладная информатика в государственном и муниципальном управлении», факультета " +
                                     $"«Информационные системы в управлении» с {first_date.Text}г. по {second_date.Text}.\n");
            document.InsertParagraph($"\tСпособ проведения практики: выездная и стационарная.");
            document.InsertParagraph($"\tСтационарная практика (без оплаты)\n").Bold();
            document.InsertParagraph($"\tОбучающихся за счет бюджетных ассигнований федерального бюджета");

            IEnumerable <Fill_data> studentsF = fill_data.Where(k => k.payable.Equals("Бюджет"));
            IEnumerable <Fill_data> studentsB = fill_data.Where(k => k.payable.Equals("Внебюджет"));

            Xceed.Document.NET.Table table     = document.AddTable(studentsF.Count() + 1, 4);
            Xceed.Document.NET.Table tabpe_pay = document.AddTable(studentsB.Count() + 1, 4);

            table.Alignment = Alignment.center;
            table.AutoFit   = AutoFit.Contents;

            tabpe_pay.Alignment = Alignment.center;
            tabpe_pay.AutoFit   = AutoFit.Contents;

            table.Rows[0].Cells[0].Paragraphs[0].Append("ФИО студента").Alignment = Alignment.center;
            table.Rows[0].Cells[1].Paragraphs[0].Append("Группа").Alignment       = Alignment.center;
            table.Rows[0].Cells[2].Paragraphs[0].Append("Место прохождения практики").Alignment = Alignment.center;
            table.Rows[0].Cells[3].Paragraphs[0].Append("Руководитель практики").Alignment      = Alignment.center;

            tabpe_pay.Rows[0].Cells[0].Paragraphs[0].Append("ФИО студента").Alignment = Alignment.center;
            tabpe_pay.Rows[0].Cells[1].Paragraphs[0].Append("Группа").Alignment       = Alignment.center;
            tabpe_pay.Rows[0].Cells[2].Paragraphs[0].Append("Место прохождения практики").Alignment = Alignment.center;
            tabpe_pay.Rows[0].Cells[3].Paragraphs[0].Append("Руководитель практики").Alignment      = Alignment.center;

            for (int i = 0; i < studentsF.Count(); i++)
            {
                table.Rows[i + 1].Cells[0].Paragraphs[0].Append(studentsF.ElementAt(i).fio);
                table.Rows[i + 1].Cells[1].Paragraphs[0].Append(combobox_groupe.SelectedItem.ToString());
                table.Rows[i + 1].Cells[2].Paragraphs[0].Append(studentsF.ElementAt(i).place);
                table.Rows[i + 1].Cells[3].Paragraphs[0].Append(combobox_otvetsven.SelectedItem.ToString());
            }

            for (int i = 0; i < studentsB.Count(); i++)
            {
                tabpe_pay.Rows[i + 1].Cells[0].Paragraphs[0].Append(studentsB.ElementAt(i).fio);
                tabpe_pay.Rows[i + 1].Cells[1].Paragraphs[0].Append(combobox_groupe.SelectedItem.ToString());
                tabpe_pay.Rows[i + 1].Cells[2].Paragraphs[0].Append(studentsB.ElementAt(i).place);
                tabpe_pay.Rows[i + 1].Cells[3].Paragraphs[0].Append(combobox_otvetsven.SelectedItem.ToString());
            }
            document.InsertParagraph().InsertTableAfterSelf(table);

            if (studentsB.Count() > 0)
            {
                document.InsertParagraph($"\tОбучающихся на платной основе");
                document.InsertParagraph().InsertTableAfterSelf(tabpe_pay);
            }
            document.InsertParagraph($"\tОтветственный по {form_pract.SelectedItem.ToString().ToLower()}  практики по кафедре в период с {first_date.Text} г. по  {second_date.Text} г. -  {combobox_otvetsven.Text} ст. преподаватель кафедры ПИЭ.");

            Classes.Direction directions = Helper.ODirections.Where(k => k.name.Equals(direct)).ElementAt(0);
            Cathedra          cathedra   = Helper.OCathedras.Where(k => k.cathedra.Equals(directions.id_cathedra)).ElementAt(0);

            document.InsertParagraph($@"
        Проректор по УР                    ________«____» ________ {first_date.SelectedDate.Value.Year}г.   С.В. Мельник
        Главный бухгалтер                ________«____» ________ {first_date.SelectedDate.Value.Year} г.  Г.И. Вилисова
        Начальник ПЭО                     ________«____» ________ {first_date.SelectedDate.Value.Year}г.   Т.В. Грачева
        Начальник ООП и СТВ          ________«____» ________{first_date.SelectedDate.Value.Year}г.   Ю.С. Сачук 
        Декан факультета «{directions.id_cathedra}»  ________«____» ________ {first_date.SelectedDate.Value.Year}г.   {cathedra.name.Remove(1)}.{cathedra.patronymic.Remove(1)}. {cathedra.surname}
        Ответственный за практику 
        и содействие трудоустройству
        на факультете                 ________«____» __________ {first_date.SelectedDate.Value.Year}г.   {cathedra.name.Remove(1)}.{cathedra.patronymic.Remove(1)}.{cathedra.surname}
");
            document.Save();
            MessageBox.Show("Документ успешно сформирован!", "Документ", MessageBoxButton.OK, MessageBoxImage.Information);
        }
示例#12
0
        public ActionResult GetDocx()
        {
            try
            {
                using (var Cargos = new EmpleadosEntities())
                {
                    var ListCargos = this.Cargos.Cargos.ToList();

                    //Ubicacion de Archivo
                    string filename = @"C:\Users\Rodrigo_Menares\Downloads\ListaCargos.docx";
                    var    doc      = DocX.Create(filename);

                    //Carga una imagen en formato JPG
                    var image = doc.AddImage(Server.MapPath("/Imagenes/bg.jpg"));
                    // Set Picture Height and Width.
                    var picture = image.CreatePicture(50, 50);
                    picture.Width  = 50;
                    picture.Height = 50;

                    //Titulo Del Documento
                    string title = "Lista De Cargos";

                    //Formato del Titulo
                    Formatting titleFormat = new Formatting();
                    //Specify font family
                    titleFormat.FontFamily = new Xceed.Document.NET.Font("Arial Black");
                    //Specify font size y color del texto
                    titleFormat.Size           = 14D;
                    titleFormat.Position       = 40;
                    titleFormat.FontColor      = System.Drawing.Color.Orange;
                    titleFormat.UnderlineColor = System.Drawing.Color.Gray;
                    titleFormat.Italic         = true;

                    //combina el titulo con el formato definido
                    Xceed.Document.NET.Paragraph paragraphTitle = doc.InsertParagraph(title, false, titleFormat);

                    // alinea el titulo al centro
                    paragraphTitle.Alignment = Alignment.center;

                    //Insert text
                    Xceed.Document.NET.Table tbl = doc.AddTable(ListCargos.Count + 1, 2);

                    //hace que la tabla este al centro de la pagina
                    tbl.Alignment = Alignment.center;
                    tbl.Design    = TableDesign.ColorfulList;

                    //agrega los titulos de la tabla
                    tbl.Rows[0].Cells[0].Paragraphs.First().Append("Código Cargo").FontSize(12D).Alignment = Alignment.center;
                    tbl.Rows[0].Cells[1].Paragraphs.First().Append("Nombre Cargo").FontSize(12D).Alignment = Alignment.center;

                    //llena las celdas con los datos
                    int fila    = 1;
                    int columna = 0;
                    foreach (var item in ListCargos)
                    {
                        tbl.Rows[fila].Cells[columna].Paragraphs.First().Append(Convert.ToString(item.Id_Carg)).FontSize(12D).Alignment = Alignment.right;
                        columna++;
                        tbl.Rows[fila].Cells[columna].Paragraphs.First().Append(Convert.ToString(item.Descr_Cargo)).FontSize(12D).Alignment = Alignment.center;
                        fila++;
                        columna = 0;
                    }

                    //inserta la tabla dentro del documento
                    doc.InsertTable(tbl);

                    //Genera el Pie de Pagina del Documento
                    doc.AddFooters();
                    //Indica que que la primera página tendrá pies de página independientes
                    doc.DifferentFirstPage = true;
                    //Indica que que la página par e impar tendrá pies de página separados
                    doc.DifferentOddAndEvenPages = true;
                    Footer    footer_main = doc.Footers.First;
                    Paragraph pFooter     = footer_main.Paragraphs.First();
                    pFooter.Alignment = Alignment.center;
                    pFooter.Append("Página ").Bold();
                    pFooter.AppendPageNumber(PageNumberFormat.normal).Bold();
                    pFooter.Append("/").Bold();
                    pFooter.AppendPageCount(PageNumberFormat.normal).Bold();

                    //graba el documento
                    doc.Save();
                    //abre word y el documento
                    Process.Start("WINWORD", filename);

                    return(RedirectToAction("Index"));
                }
            }
            catch (Exception ex)
            {
                Logger.Error("Error On:", ex);
                Response.StatusCode        = 500;
                Response.StatusDescription = ex.Message;
                return(Json(Response));
            }
        }
示例#13
0
        private void btnExport_Click(object sender, RoutedEventArgs e)
        {
            string fileName = $"bestelbon-{ ((isLeverancier) ? "Leveranciers" : "Klanten") }\\{txtDatum.Text} {txtBonId.Text}-{txtNaam.Text}.docx";

            if (File.Exists(fileName))
            {
                File.Delete(fileName);
            }
            try
            {
                var doc = DocX.Create(fileName);

                Picture img = doc.AddImage("img\\2492003.jpg").CreatePicture();
                doc.InsertParagraph().AppendPicture(img);
                doc.InsertParagraph("Company adress");
                doc.InsertParagraph("Company phone");
                doc.AddHyperlink("www.CompanyWebsite.be", new Uri("http://www.CompanyWebsite.be"));
                doc.InsertParagraph();

                Xceed.Document.NET.Table ct = doc.AddTable(1, 2);
                ct.Rows[0].Cells[0].Paragraphs.First().Append("Iban:");
                ct.Rows[0].Cells[0].Paragraphs.First().Append("BIC:");
                ct.Rows[0].Cells[0].Paragraphs.First().Append("OnderNemingsnr:");
                ct.Rows[0].Cells[0].Paragraphs.First().Append("BTWnr.:");

                ct.Rows[0].Cells[1].Paragraphs.First().Append($"{txtKlant.Text} {txtKlantnr.Text}");
                ct.Rows[0].Cells[1].Paragraphs.First().Append(txtNaam.Text);
                ct.Rows[0].Cells[1].Paragraphs.First().Append(txtAdress.Text);
                ct.Rows[0].Cells[1].Paragraphs.First().Append(txtGemeente.Text);
                ct.Rows[0].Cells[1].Paragraphs.First().Append(txtTelefoon.Text);
                ct.Rows[0].Cells[1].Paragraphs.First().Append(txtMail.Text);
                doc.InsertTable(ct);
                doc.InsertParagraph();
                using (tussentijds_projectEntities1 ctx = new tussentijds_projectEntities1())
                {
                    var ProductList = ctx.BestellingProducts.Where(s => s.BestellingID == bestellingID).Select(s => s.Product).Select(s => new
                    {
                        s,
                        Beschrijving = s.Naam + " ( " + s.Leverancier.Contactpersoon + " )",
                        Prijs        = "€ " + Math.Round((double)s.Eenheid, 2),
                        Btw          = s.BTW + "%",
                        Netto        = "€ " + Math.Round((double)(s.Eenheid + ((s.Eenheid / 100) * s.BTW)), 2)
                    }).ToList();

                    Xceed.Document.NET.Table t = doc.AddTable(ProductList.Count() + 1, 5);
                    t.Rows[0].Cells[0].Paragraphs.First().Append("Id");
                    t.Rows[0].Cells[1].Paragraphs.First().Append("beschrijving");
                    t.Rows[0].Cells[2].Paragraphs.First().Append("Eenheidsprijs");
                    t.Rows[0].Cells[3].Paragraphs.First().Append("Btw");
                    t.Rows[0].Cells[4].Paragraphs.First().Append("Netto");
                    for (int i = 0; i < ProductList.Count(); i++)
                    {
                        t.Rows[i + 1].Cells[0].Paragraphs.First().Append(ProductList[i].s.ProductID.ToString());
                        t.Rows[i + 1].Cells[1].Paragraphs.First().Append(ProductList[i].Beschrijving);
                        t.Rows[i + 1].Cells[2].Paragraphs.First().Append(ProductList[i].Prijs);
                        t.Rows[i + 1].Cells[3].Paragraphs.First().Append(ProductList[i].Btw);
                        t.Rows[i + 1].Cells[4].Paragraphs.First().Append(ProductList[i].Netto);
                    }
                    doc.InsertTable(t);
                }
                doc.InsertParagraph($"totaal zonder btw:  €{txtEenTotaal.Text}");
                doc.InsertParagraph($"btw: +€{txtBtwTotaal.Text}");
                doc.InsertParagraph($"Totaal: €{txtTotaal.Text}");
                doc.InsertParagraph();
                doc.InsertParagraph();
                doc.InsertParagraph("Verkoper:");
                doc.InsertParagraph(txtverkoper.Text);

                doc.Save();
            }
            catch (Exception error)
            {
                MessageBox.Show(error.Message);
            }
        }
示例#14
0
        static void Main(string[] args)
        {
            //string path = "test-doc.rtf";
            //string readText = File.ReadAllText(path);
            //var docin = DocX.Load(RtfDocx(readText));
            //var tins = docin.Tables[0];

            string fileName = @"exempleWord.docx";

            doc = DocX.Create(fileName);

            doc.PageLayout.Orientation = Orientation.Landscape;

            //Formatting Text Paragraph
            Formatting textParagraphFormat = new Formatting
            {
                //font family
                FontFamily = new Font("Times New Roman"),
                //font size
                Size = 10D,
                //Spaces between characters
                //Spacing = 1
            };



            //Create Table with 2 rows and 3 columns.
            var   header = new string[] { "Было", "Статус", "Стало" };
            Table t      = doc.AddTable(2, header.Length);

            t.Alignment = Alignment.center;
            t.SetWidthsPercentage(new float[] { 45F, 10F, 45F }, doc.PageWidth - 40);
            // t.Design = TableDesign.TableGrid;SetColumnWidth(t, new int[] { 45, 10, 45 }, doc.PageWidth);
            //t.AutoFit = AutoFit.Fixed;
            //            t.SetWidthsPercentage(new float[] { 45F,10F, 45F },doc.PageWidth);

            SetColumnWidth(t, new int[] { 45, 10, 45 }, doc.PageWidth - 40);
            FillRow(t.Rows[0], header, System.Drawing.Color.LightGray, true);


            Globals.Load_CradleAPI();
            Globals.GetArgs();
            //&TBL2&ПД&BL0&БЛ1&&Рзд ПД-37&ТЛ-1
            var bl1   = Globals.Args[3];
            var bl2   = Globals.Args[4];
            var phase = Globals.Args[2];
            var proj  = new Project();
            var ldap  = new LDAPInformation();

            if (!proj.Connect(Globals.CRADLE_CDS_HOST, Globals.CRADLE_PROJECT_CODE, Globals.CRADLE_USERNAME, Globals.CRADLE_PASSWORD, true,
                              Cradle.Server.Connection.API_LICENCE, ldap, false))
            {
                return;
            }
            ;
            var project = proj;

            proj.SetBaselineMode(CAPI_BASELINE_MODE.SPECIFIED, bl2);
            Console.WriteLine("Начало обработки проекта " + proj.Title);

            int row = 1;

            Item root = new Item(CAPI_INFO.NOTE, "Раздел ТЗ " + phase);

            root.Identity = Globals.Args[6];
            root.Baseline = bl2;
            root.Version  = "01";
            root.Draft    = " ";
            if (root.Open(false))
            {
                root.Close();
                OutItems(t, root, ref row);
            }
            //SetColumnWidth(t,new int[] { 45, 10, 45 }, doc.PageWidth);

            doc.InsertTable(t);
            //SetColumnWidth(t, new int[] { 45, 10, 45 }, doc.PageWidth);
            //doc.InsertDocument(docin);
            doc.Save();
            Process.Start("WINWORD.EXE", fileName);
        }
示例#15
0
        static void OutItems(Table gtable, Item it, ref int row)
        {
            int myrow = row;

            //sl.InsertRow();
            //row++;
            Console.Write(".");

            {
                LinkedItem linked_item  = null;
                List       linked_items = null;
                Navigation nav          = null;
                int        num_linked_items;
                nav = new Navigation();

                nav.Type = "Включает";

                nav.Direction = CAPI_XREF_DIR.ONLY_DOWN;
                // Get linked items
                if (it.GetLinkedItems(CAPI_LINKS.ALL, nav, CAPI_INFO.NOTE, CAPI_SUBTYPE.NULL, "", null, default(int), default(QueryStereotypeTest), default(QueryModelviewTest), null, out linked_items))
                {
                    num_linked_items = linked_items.Length;
                    var loopTo = num_linked_items - 1;
                    for (int i = 0; i <= loopTo; i++)
                    {
                        if (linked_items.GetElement(i, out linked_item))
                        {
                            var            l_it       = linked_item.Item;
                            Frame          frame      = null;
                            string         frame_text = null;
                            BinaryContents frame_tbl  = null;
                            BinaryContents frame_pic  = null;
                            DocX           docin      = null;
                            Table          tins       = null;
                            Picture        pins       = null;
                            Paragraph      par        = null;
                            l_it.Open(false);
                            if (!l_it.GetFrame("TEXT", out frame))
                            {
                                return;
                            }

                            // Get TEXT frame contents
                            if (!frame.GetContents(out frame_text))
                            {
                                return;
                            }
                            if (l_it.NoteType != "Титульный лист")
                            {
                                if (!l_it.GetFrame("Таблица", out frame))
                                {
                                    return;
                                }

                                // Get  frame contents
                                if (!frame.GetContents(out frame_tbl))
                                {
                                    return;
                                }
                                if (frame_tbl.Size != 0)
                                {
                                    byte[] memdocx = new byte[frame_tbl.Size];
                                    IntPtr pnt     = frame_tbl.Data;

                                    Marshal.Copy(pnt, memdocx, 0, memdocx.Length);
                                    docin = DocX.Load(BRtfDocx(memdocx));
                                    tins  = docin.Tables[0];
                                }
                                if (!l_it.GetFrame("Рисунок", out frame))
                                {
                                    return;
                                }

                                // Get  frame contents
                                if (!frame.GetContents(out frame_pic))
                                {
                                    return;
                                }
                                if (frame_pic.Size != 0)
                                {
                                    byte[] memdocx = new byte[frame_pic.Size];
                                    IntPtr pnt     = frame_pic.Data;

                                    Marshal.Copy(pnt, memdocx, 0, memdocx.Length);
                                    Stream stream = BRtfImage(memdocx);
                                    stream.Position = 0;

                                    Image img = doc.AddImage(stream);
                                    pic = img.CreatePicture();
                                    double scale = (double)pic.Width / (double)pic.Height;
                                    pic.WidthInches  = 3;
                                    pic.HeightInches = pic.WidthInches / scale;
                                }
                            }

                            l_it.Close();

                            gtable.InsertRow();
                            row++;
                            gtable.Rows[row].Cells[1].Paragraphs.First().Append(l_it.Identity);
                            //gtable.Rows[row].Cells[2].InsertParagraph().Append(frame_text);
                            gtable.Rows[row].Cells[2].Paragraphs.First().Append(frame_text);
                            if (frame_tbl != null)
                            {
                                if (frame_tbl.Size != 0)
                                {
                                    gtable.Rows[row].Cells[2].InsertParagraph().InsertTableAfterSelf(tins);
                                    gtable.Rows[row].Cells[2].InsertParagraph(docin.InsertParagraph(""));
                                }
                            }
                            if (frame_pic != null)
                            {
                                if (frame_pic.Size != 0)
                                {
                                    //Image img = doc.AddImage(bRtfDocx(memdocx));
                                    //Picture pic = img.CreatePicture();
                                    //gtable.Rows[row].Cells[0].Paragraphs.First().InsertPicture(pic);
                                    gtable.Rows[row].Cells[2].InsertParagraph().InsertPicture(pic);
                                    //gtable.Rows[row].Cells[2].InsertParagraph(doc.InsertParagraph(""));
                                }
                            }
                            //sl.InsertRow();
                        }
                    }
                    linked_items.Dispose();
                }

                nav.Type = "Содержит";

                nav.Direction = CAPI_XREF_DIR.ONLY_DOWN;
                // Get linked items
                if (it.GetLinkedItems(CAPI_LINKS.ALL, nav, CAPI_INFO.NOTE, CAPI_SUBTYPE.NULL, "", null, default(int), default(QueryStereotypeTest), default(QueryModelviewTest), null, out linked_items))
                {
                    num_linked_items = linked_items.Length;
                    var loopTo = num_linked_items - 1;
                    for (int i = 0; i <= loopTo; i++)
                    {
                        if (linked_items.GetElement(i, out linked_item))
                        {
                            var l_it = linked_item.Item;
                            gtable.InsertRow();
                            row++;
                            OutItems(gtable, l_it, ref row);
                        }
                    }
                    linked_items.Dispose();
                }

                gtable.Rows[myrow].Cells[1].Paragraphs.First().Append(it.Identity);
                gtable.Rows[myrow].Cells[2].Paragraphs.First().Append(it.Name);
                //sl.InsertRow();

                return;
            }
        }
示例#16
0
 public void OpenBlank(Exam exam, Ticket ticket, bool markAnswers)
 {
     CloseWord();
     using (DocX docXdocument = DocX.Create(path.ToString()))
     {
         int i, j;
         docXdocument.AddFooters();
         docXdocument.SetDefaultFont(new Xceed.Document.NET.Font("Times New Roman"), 14);
         Xceed.Document.NET.Paragraph headerParagraph = docXdocument.InsertParagraph();
         Xceed.Document.NET.Paragraph paragraph       = docXdocument.InsertParagraph();
         headerParagraph.Append($"Виконання завдань")
         .Bold()
         .FontSize(16);
         paragraph = docXdocument.InsertParagraph();
         paragraph.Append($"Здобувач освіти")
         .Bold()
         .Append("\t\t\t\t\t\t\t")
         .UnderlineStyle(UnderlineStyle.singleLine)
         .Append("білет №")
         .Bold()
         .Append("\t\t")
         .UnderlineStyle(UnderlineStyle.singleLine);
         paragraph = docXdocument.InsertParagraph();
         paragraph.Append($"{Environment.NewLine}I частина")
         .Bold()
         .Alignment = Alignment.center;
         paragraph  = docXdocument.InsertParagraph();
         paragraph.Append($"\tОзнайомтесь з тестовим завданням. Дайте відповіді на тестові завдання в таблиці" +
                          $"(поряд із номером запитання зазначте номер правильної відповіді){Environment.NewLine}")
         .Alignment = Alignment.left;
         List <OneAnswerQuestion[]> questionLists = new List <OneAnswerQuestion[]>();
         for (i = 0; i < exam.Themes.Count; i++)
         {
             OneAnswerQuestion[] questions = exam.Themes[i].GetQuestions(ticket).Cast <OneAnswerQuestion>().ToArray();
             Array.Sort(questions,
                        (Question a, Question b) =>
             {
                 if (a.QuestionNumber > b.QuestionNumber)
                 {
                     return(1);
                 }
                 else if (a.QuestionNumber < b.QuestionNumber)
                 {
                     return(-1);
                 }
                 return(0);
             });
             questionLists.Add(questions);
         }
         int max = questionLists.Max(a => a.Length);
         Xceed.Document.NET.Table table = docXdocument.AddTable(max + 1, questionLists.Count * 2);
         table.SetBorder(TableBorderType.Bottom, new Xceed.Document.NET.Border(BorderStyle.Tcbs_double, BorderSize.two, 0, Color.Black));
         table.SetBorder(TableBorderType.Top, new Xceed.Document.NET.Border(BorderStyle.Tcbs_double, BorderSize.two, 0, Color.Black));
         table.SetBorder(TableBorderType.Left, new Xceed.Document.NET.Border(BorderStyle.Tcbs_double, BorderSize.two, 0, Color.Black));
         table.SetBorder(TableBorderType.Right, new Xceed.Document.NET.Border(BorderStyle.Tcbs_double, BorderSize.two, 0, Color.Black));
         List <float> percentages = new List <float>();
         float        pa          = 30 / (table.ColumnCount / 2);
         float        pb          = 70 / (table.ColumnCount / 2);
         for (i = 0; i < table.ColumnCount / 2; i += 2)
         {
             table.Rows[0].MergeCells(i, i + 1);
             percentages.Add(pa);
             percentages.Add(pb);
             i--;
         }
         table.SetWidthsPercentage(percentages.ToArray(), docXdocument.PageWidth - docXdocument.PageWidth / 5);
         for (i = 0; i < exam.Themes.Count; i++)
         {
             table.Rows[0].Cells[i].InsertParagraph()
             .Append(exam.Themes[i].ThemeName)
             .Alignment = Alignment.center;
         }
         for (i = 0; i < table.ColumnCount / 2; i++)
         {
             for (j = 0; j < questionLists[i].Length; j++)
             {
                 table.Rows[1 + j].Cells[i * 2].InsertParagraph()
                 .Append($"{questionLists[i][j].QuestionNumber + exam.FirstQuestionNumber}");
                 if (markAnswers)
                 {
                     int index = questionLists[i][j].QuestionContent.Answers.IndexOf(questionLists[i][j].Answer.Content);
                     table.Rows[1 + j].Cells[i * 2 + 1].InsertParagraph()
                     .Append(index >= 0 && index < questionLists[i][j].QuestionContent.Letters.Length ? questionLists[i][j].QuestionContent.Letters[index].ToString() : "*");
                 }
             }
         }
         docXdocument.InsertTable(table);
         paragraph = docXdocument.InsertParagraph();
         paragraph.Append($"{Environment.NewLine}{Environment.NewLine}Балл: ")
         .Bold()
         .Alignment = Alignment.right;
         if (!markAnswers)
         {
             paragraph.Append("\t\t")
             .UnderlineStyle(UnderlineStyle.singleLine)
             .Alignment = Alignment.right;
         }
         else
         {
             paragraph.Append($"{ticket.MaxPoints:F2}")
             .UnderlineStyle(UnderlineStyle.singleLine)
             .Alignment = Alignment.right;
         }
         docXdocument.Footers.Odd.InsertParagraph()
         .Append("Створено за допомогою SimplEx Program")
         .FontSize(10)
         .UnderlineStyle(UnderlineStyle.singleLine)
         .Alignment = Xceed.Document.NET.Alignment.right;
         docXdocument.Save();
     }
     OpenWord();
 }