Represents a Table in a document.
Наследование: InsertBeforeOrAfter
Пример #1
1
        private static void TablazatFormazas( Table table ) {
            table.AutoFit = AutoFit.Contents;
            table.AutoFit = AutoFit.ColumnWidth;
            foreach( Row row in table.Rows ) {
                row.Cells[0].Width = 30;
                row.Cells[1].Width = 50;
                row.Cells[2].Width = 50;
                row.Cells[3].Width = 200;
                row.Cells[4].Width = 200;
                row.Cells[5].Width = 70;
                row.Cells[6].Width = 70;
            }

            Border c = new Border(Novacode.BorderStyle.Tcbs_none, BorderSize.seven, 0, Color.Black);
            Border d = new Border(Novacode.BorderStyle.Tcbs_single, BorderSize.five, 0, Color.Black);
            table.SetBorder( TableBorderType.InsideH, d );
            table.SetBorder( TableBorderType.InsideV, c );
            table.SetBorder( TableBorderType.Bottom, c );
            table.SetBorder( TableBorderType.Top, c );
            table.SetBorder( TableBorderType.Left, c );
            table.SetBorder( TableBorderType.Right, c );

        }
Пример #2
0
        private void FillPurchases(DocX doc)
        {
            IEnumerable <LBCFUBL_WCF.DBO.Purchase> purchases = Helper
                                                               .GetPurchaseClient()
                                                               .GetPurchases()
                                                               .OrderBy(x => x.date)
                                                               .OrderBy(x => x.login)
                                                               .ThenBy(x => x.Product.name)
                                                               .Where(x => x.date >= from && x.date <= to);

            Novacode.Table table = doc.AddTable(purchases.Count() + 1, 4);
            setTableStyle(table);

            table.Rows[0].Cells[0].InsertParagraph().Append("Login").Bold();
            table.Rows[0].Cells[1].InsertParagraph().Append("Date").Bold();
            table.Rows[0].Cells[2].InsertParagraph().Append("Produit").Bold();
            table.Rows[0].Cells[3].InsertParagraph().Append("Prix").Bold();

            int i = 1;

            foreach (LBCFUBL_WCF.DBO.Purchase purchase in purchases)
            {
                table.Rows[i].Cells[0].InsertParagraph().Append(purchase.login);
                table.Rows[i].Cells[1].InsertParagraph().Append(purchase.date.ToString("dd-MM-yyyy hh:mm"));
                table.Rows[i].Cells[2].InsertParagraph().Append(purchase.Product.name);
                table.Rows[i].Cells[3].InsertParagraph().Append(currency(purchase.Product.cost_with_margin));
                i++;
            }

            doc.InsertTable(table);
        }
Пример #3
0
        private void FillAccounts(DocX doc)
        {
            IEnumerable <LBCFUBL_WCF.DBO.Account> accounts = Helper
                                                             .GetAccountClient()
                                                             .GetAccounts()
                                                             .OrderBy(x => x.login)
                                                             .Where(x => x.date >= from && x.date <= to);

            Novacode.Table table = doc.AddTable(accounts.Count() + 1, 3);
            setTableStyle(table);

            table.Rows[0].Cells[0].InsertParagraph().Append("Login").Bold();
            table.Rows[0].Cells[1].InsertParagraph().Append("Date").Bold();
            table.Rows[0].Cells[2].InsertParagraph().Append("Argent").Bold();

            int i = 1;

            foreach (LBCFUBL_WCF.DBO.Account account in accounts)
            {
                table.Rows[i].Cells[0].InsertParagraph().Append(account.login);
                table.Rows[i].Cells[1].InsertParagraph().Append(account.date.ToString("dd-MM-yyyy hh:mm"));
                table.Rows[i].Cells[2].InsertParagraph().Append(currency(account.argent));
                i++;
            }

            doc.InsertTable(table);
        }
Пример #4
0
        public object Tagify(DocX word, string model)
        {
            // Patterns
            string inlinePattern = this.ModelPattern.Replace("<model>", model);
            string blockPattern  = this.PointerPattern.Replace("<model>", model);

            // Get inline templates
            List <string> inlineTemplates = word.FindUniqueByPattern(inlinePattern, this.REGEX);

            // Get block templates
            List <Novacode.Table> blockTemplates;

            try
            {
                Novacode.Table blockTemplatesWrapper = word
                                                       .Tables
                                                       .Where(e => e.Paragraphs[0].Text.Contains(blockPattern))
                                                       .ToList()[0];

                blockTemplates = this.CascadeBlock(blockTemplatesWrapper, new List <Novacode.Table>());
            }
            catch (Exception e)
            {
                blockTemplates = new List <Novacode.Table>();
            }

            return(new
            {
                name = model,
                inlines = inlineTemplates,
                blocks = blockTemplates
            });
        }
Пример #5
0
        private void AddRowWithReplacements(Table tbl, RollsheetPersonInfo m, int orgId)
        {
            var row = tbl.InsertRow(docx.Tables[0].Rows[0]);

            tbl.Rows.Add(row);
            var dict = replacements.DocXReplacementsDictionary(m.Person, orgId);

            foreach (var p in row.Paragraphs.Where(vv => vv.Text.HasValue()))
            {
                if (dict.Keys.Any(vv => p.Text.Contains(vv)))
                {
                    foreach (var d in dict)
                    {
                        if (p.Text.Contains(d.Key))
                        {
                            if (d.Key == "{barcodepeopleid}")
                            {
                                var s   = BarCodeStream(m.Person.PeopleId.ToString(), 40, showtext: false);
                                var img = curr.AddImage(s);
                                p.AppendPicture(img.CreatePicture());
                                p.ReplaceText(d.Key, "");
                            }
                            else if (d.Key.Equal("{MLG}"))
                            {
                                p.ReplaceText(d.Key, m.MemberTypeCode);
                            }
                            else if (d.Key.Equal("{highlight}"))
                            {
                                if (m.Highlight.HasValue())
                                {
                                    p.ReplaceText(d.Key, m.Highlight);
                                }
                                else
                                {
                                    p.Remove(false);
                                }
                            }
                            else if (d.Key.Equal("{altname}"))
                            {
                                p.ReplaceText(d.Key, m.UseAltName ? m.Person.AltName : "");
                            }
                            else if (d.Key.Equal("{name}"))
                            {
                                p.ReplaceText(d.Key, m.Person.Name2);
                                if (m.MemberTypeCode == "VS")
                                {
                                    row.Cells.Last().Shading = Color.FromArgb(226, 239, 217); // light green
                                }
                            }
                            else
                            {
                                p.ReplaceText(d.Key, d.Value);
                            }
                        }
                    }
                }
            }
        }
Пример #6
0
        public static void CreateTestReport(Patient patient, MedicalTest test, string file_path)
        {
            if (file_path == null)
            {
                return;
            }
            Type test_type = test.GetType();

            using (DocX document = DocX.Create(file_path))
            {
                Novacode.Paragraph header = document.InsertParagraph(
                    //selected_procedure.ProcedureType.First().ToString().ToUpper() + String.Join("", selected_procedure.ProcedureType.Skip(1)).ToLower(),
                    test_type.GetCustomAttribute <DisplayNameAttribute>().DisplayName,
                    false,
                    new Formatting()
                {
                    FontFamily = new System.Drawing.FontFamily("Times New Roman"),
                    Size       = 16D
                }
                    );
                header.Alignment = Alignment.center;
                header.Bold();
                document.InsertParagraph(" ");
                Novacode.Table patient_info = document.AddTable(5, 2);
                patient_info.Rows[0].Cells[0].Paragraphs.First().Append("ФИО пациента").Bold();
                patient_info.Rows[0].Cells[1].Paragraphs.First().Append(patient.LastName + " " + patient.FirstName + " " + patient.Patronym);
                patient_info.Rows[1].Cells[0].Paragraphs.First().Append("Пол").Bold();
                patient_info.Rows[1].Cells[1].Paragraphs.First().Append(patient.Sex == Sex.мужской ? "мужской" : "женский");
                patient_info.Rows[2].Cells[0].Paragraphs.First().Append("Дата рождения").Bold();
                patient_info.Rows[2].Cells[1].Paragraphs.First().Append(patient.Birthdate.ToShortDateString());
                patient_info.Rows[3].Cells[0].Paragraphs.First().Append("Адрес проживания").Bold();
                patient_info.Rows[3].Cells[1].Paragraphs.First().Append(
                    patient.PostIndex + ", " + patient.Country + ", " + patient.Region +
                    ", " + patient.City + ", " + patient.Address
                    );
                patient_info.Rows[4].Cells[0].Paragraphs.First().Append("Номер карты").Bold();
                patient_info.Rows[4].Cells[1].Paragraphs.First().Append(patient.CardNumber.ToString());
                patient_info.Alignment = Alignment.left;
                patient_info.AutoFit   = AutoFit.Window;
                PropertyInfo[] indicators = test_type.GetProperties().Where(x => x.IsDefined(typeof(TestInfo))).ToArray();
                Novacode.Table test_info  = document.AddTable(indicators.Count(), 2);
                int            k          = 0;
                foreach (var indicator in indicators)
                {
                    test_info.Rows[k].Cells[0].Paragraphs.First().Append(indicator.GetCustomAttribute <TestInfo>().DisplayName);
                    object property_value = indicator.GetValue(test);
                    test_info.Rows[k].Cells[1].Paragraphs.First().Append(property_value != null ? property_value.ToString() : "");
                    k++;
                }
                test_info.Alignment = Alignment.left;
                test_info.AutoFit   = AutoFit.Window;
                document.InsertTable(patient_info);
                document.InsertParagraph(" ");
                document.InsertTable(test_info);
                document.Save();
            }
        }
Пример #7
0
        public void ToReport(string filePath, ref Novacode.Table tbl, int i, int language)
        {
            List <string> comments = comment.GetComments();

            tbl.Rows[i].Cells[0].Paragraphs.First().Append(name);
            tbl.Rows[i].Cells[1].Paragraphs.First().Append(_type);
            tbl.Rows[i].Cells[2].Paragraphs.First().Append(_isNull.ToString());
            tbl.Rows[i].Cells[3].Paragraphs.First().Append(_defaultValue);
            tbl.Rows[i].Cells[4].Paragraphs.First().Append(comments[language]);
        }
Пример #8
0
        public string getCVS(Novacode.Table table)
        {
            string tableHeaderContainCVE = "VULNERABILITY SEVERITY RATING AND MAXIMUM SECURITY IMPACT BY AFFECTED SOFTWARE";

            if ((table.Rows[0].Cells.Count == 1) && (tableHeaderContainCVE.Equals(table.Rows[0].Cells[0].Paragraphs[0].Text.ToUpper().Trim())))
            {
                return(concatCVEs(table.Rows[1]));
            }
            return("");
        }
Пример #9
0
 public void FillData(Table table)
 {
     for (int i = 1; i < 5; i++)
     {
         for (int j = 0; j < 5; j++)
         {
             table.Rows[i].Cells[j].Paragraphs[0].Append(string.Format("Rows:{0} Columns:{1}", i, j));
         }
     }
 }
Пример #10
0
        private static Table CreateAndInsertInvoiceTableAfter(Table t, ref DocX document)
        {
            // Grab data from somewhere (Most likely a database)
            schooldbEntities DAO = new schooldbEntities();
            List<teacher> tlist = (from tt in DAO.teachers select tt).ToList<teacher>();

            /*
             * The trick to replacing one Table with another,
             * is to insert the new Table after the old one,
             * and then remove the old one.
             */
            Table invoice_table = t.InsertTableAfterSelf(tlist.Count + 1, 4);
            invoice_table.Design = TableDesign.LightShadingAccent1;

            #region Table title
            Formatting table_title = new Formatting();
            table_title.Bold = true;

            invoice_table.Rows[0].Cells[0].Paragraph.InsertText("Serial No.", false, table_title);
            invoice_table.Rows[0].Cells[0].Paragraph.Alignment = Alignment.center;
            invoice_table.Rows[0].Cells[1].Paragraph.InsertText("Employee Name", false, table_title);
            invoice_table.Rows[0].Cells[1].Paragraph.Alignment = Alignment.center;
            invoice_table.Rows[0].Cells[2].Paragraph.InsertText("Account No.", false, table_title);
            invoice_table.Rows[0].Cells[2].Paragraph.Alignment = Alignment.center;
            invoice_table.Rows[0].Cells[3].Paragraph.InsertText("Salary", false, table_title);
            invoice_table.Rows[0].Cells[3].Paragraph.Alignment = Alignment.center;
            #endregion

            // Loop through the rows in the Table and insert data from the data source.
            for (int row = 1; row < tlist.Count; row++)
            {

                    Paragraph cell_paragraph = invoice_table.Rows[row].Cells[0].Paragraph;
                    cell_paragraph.InsertText(row.ToString(), false);

                    cell_paragraph = invoice_table.Rows[row].Cells[1].Paragraph;
                    cell_paragraph.InsertText(tlist[row - 1].TeacherName.ToString(), false);

                    cell_paragraph = invoice_table.Rows[row].Cells[2].Paragraph;
                    cell_paragraph.InsertText(tlist[row - 1].Account_Number.ToString(), false);

                    cell_paragraph = invoice_table.Rows[row].Cells[3].Paragraph;
                    cell_paragraph.InsertText(tlist[row - 1].BasicSalary.ToString(), false);

            }

            // Let the tables coloumns expand to fit its contents.
            invoice_table.AutoFit = AutoFit.Contents;

            // Center the Table
            invoice_table.Alignment = Alignment.center;

            // Return the invloce table now that it has been created.
            return invoice_table;
        }
Пример #11
0
        private void ExportWordTable()
        {
            List <SINHVIENEntities> lstSINHVIEN = dapSINHVIEN.GetAll();

            if (lstSINHVIEN != null)
            {
                //Khai báo đường dẫn của file sau khi lưu
                string urlFileSave = "/AppFile/tmp/ListSV.docx";
                urlFileSave = Server.MapPath(urlFileSave);
                //Khai báo đường dẫn của file doc được đọc
                string fileName = Server.MapPath("/AppFile/Docs/ExportWordTable.docx");

                using (DocX doc = DocX.Load(fileName))
                {
                    Novacode.Table tblSINHVIEN = doc.Tables[1];
                    Novacode.Row   rowCn       = tblSINHVIEN.Rows[1];
                    int            count       = 2;
                    Novacode.Row   newRow;

                    for (int i = 0; i < lstSINHVIEN.Count; i++)
                    {
                        newRow = tblSINHVIEN.InsertRow(rowCn, count++);
                        newRow.Cells[0].ReplaceText("@stt", (i + 1).ToString());
                        newRow.Cells[1].ReplaceText("@hovaten", lstSINHVIEN[i].HOVATEN == null ? "" : lstSINHVIEN[i].HOVATEN);
                        newRow.Cells[2].ReplaceText("@ngaysinh", lstSINHVIEN[i].NGAYSINH == null ? "" : lstSINHVIEN[i].NGAYSINH.ToString("dd/MM/yyyy"));
                        newRow.Cells[3].ReplaceText("@gioitinh", lstSINHVIEN[i].GIOITINH == 1 ? "Nam" : "Nữ");
                        newRow.Cells[4].ReplaceText("@diachi", lstSINHVIEN[i].DIACHI == null ? "" : lstSINHVIEN[i].DIACHI);
                        newRow.Cells[5].ReplaceText("@sdt", lstSINHVIEN[i].SDT == null ? "" : lstSINHVIEN[i].SDT);
                        newRow.Cells[6].ReplaceText("@email", lstSINHVIEN[i].EMAIL == null ? "" : lstSINHVIEN[i].EMAIL);
                        newRow.Cells[7].ReplaceText("@lop", lstSINHVIEN[i].TENLOP);
                    }
                    tblSINHVIEN.RemoveRow(1);
                    doc.SaveAs(urlFileSave);
                    doc.Save();
                    Response.Buffer  = true;
                    Response.Expires = 0;
                    Response.Clear();
                    string strHttpContext_ContentType = "application/msword";
                    HttpContext.Current.Response.ContentType     = strHttpContext_ContentType;
                    HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.UTF8;
                    HttpContext.Current.Response.Charset         = "utf-8";
                    Response.AddHeader("Content-Disposition", "attachment; filename=BangThongTinSinhVien" + ".docx");
                    Response.TransmitFile(urlFileSave);
                    Response.Flush();
                    Response.Close();
                    Response.End();
                }
            }
        }
Пример #12
0
        public List <Novacode.Table> CascadeBlock(Novacode.Table block, List <Novacode.Table> blocks)
        {
            blocks.Add(block);

            try
            {
                block = block.Rows[1].Tables[0];

                return(this.CascadeBlock(block, blocks));
            }
            catch (Exception e)
            {
                return(blocks);
            }
        }
Пример #13
0
        public void ToReport(string filePath, ref DocX document, int language)
        {
            List <string> commentString = new List <string>();

            commentString.Add("Comment: ");
            commentString.Add("Коментар: ");
            commentString.Add("Комментарий: ");

            List <string> comments = comment.GetComments();

            document.InsertParagraph(commentString[language] + comments[language] + "\r\n");
            Novacode.Table table = document.AddTable(fields.Count, 5);
            table.Alignment = Alignment.center;
            table.Design    = TableDesign.LightShadingAccent2;
            Novacode.Table tbl = document.InsertTable(table);

            if (language == 0)
            {
                tbl.Rows[0].Cells[0].Paragraphs.First().Append("Name").FontSize(12);
                tbl.Rows[0].Cells[1].Paragraphs.First().Append("Type");
                tbl.Rows[0].Cells[2].Paragraphs.First().Append("Is Null");
                tbl.Rows[0].Cells[3].Paragraphs.First().Append("Default value");
                tbl.Rows[0].Cells[4].Paragraphs.First().Append("Comment");
            }
            else if (language == 1)
            {
                tbl.Rows[0].Cells[0].Paragraphs.First().Append("Назва");
                tbl.Rows[0].Cells[1].Paragraphs.First().Append("Тип");
                tbl.Rows[0].Cells[2].Paragraphs.First().Append("Пусті значення");
                tbl.Rows[0].Cells[3].Paragraphs.First().Append("Значення по замовченню");
                tbl.Rows[0].Cells[4].Paragraphs.First().Append("Коментар");
            }
            else
            {
                tbl.Rows[0].Cells[0].Paragraphs.First().Append("Название");
                tbl.Rows[0].Cells[1].Paragraphs.First().Append("Тип");
                tbl.Rows[0].Cells[2].Paragraphs.First().Append("Пустые значения");
                tbl.Rows[0].Cells[3].Paragraphs.First().Append("Значение по умолчанию");
                tbl.Rows[0].Cells[4].Paragraphs.First().Append("Комментарий");
            }
            for (int i = 1; i < fields.Count; i++)
            {
                fields[i].ToReport(filePath, ref tbl, i, language);
            }
            document.InsertParagraph("\r\n");
        }
Пример #14
0
        private void FillUsersInfos(DocX doc)
        {
            IEnumerable <LBCFUBL_WCF.DBO.User> users = Helper
                                                       .GetUserClient()
                                                       .GetUsers()
                                                       .OrderBy(x => x.login);

            Novacode.Table table = doc.AddTable(users.Count() + 1, 4);
            setTableStyle(table);

            table.Rows[0].Cells[0].InsertParagraph().Append("Login").Bold();
            table.Rows[0].Cells[1].InsertParagraph().Append("Accompte").Bold();
            table.Rows[0].Cells[2].InsertParagraph().Append("Dette").Bold();
            table.Rows[0].Cells[3].InsertParagraph().Append("Balance").Bold();

            int i = 1;

            foreach (LBCFUBL_WCF.DBO.User user in users)
            {
                double totalAccount = Helper
                                      .GetAccountClient()
                                      .GetAccountsForLogin(user.login)
                                      .Where(x => x.date <= to)
                                      .Sum(x => x.argent) - Helper
                                      .GetPurchaseClient()
                                      .GetPurchasesForLogin(user.login)
                                      .Where(x => x.date <= from)
                                      .Sum(x => x.Product.cost_with_margin);

                double totalPurchases = Helper
                                        .GetPurchaseClient()
                                        .GetPurchasesForLogin(user.login)
                                        .Where(x => x.date >= from && x.date <= to)
                                        .Sum(x => x.Product.cost_with_margin);

                table.Rows[i].Cells[0].InsertParagraph().Append(user.login);
                table.Rows[i].Cells[1].InsertParagraph().Append(currency(totalAccount));
                table.Rows[i].Cells[2].InsertParagraph().Append(currency(totalPurchases));
                table.Rows[i].Cells[3].InsertParagraph().Append(currency(totalAccount - totalPurchases));

                i++;
            }

            doc.InsertTable(table);
        }
Пример #15
0
 //Extracts the content of a Individual Table
 private void extractTableContent(Novacode.Table table)
 {
     //myTable.setSystemOrComponent(table.Rows[0]);
     myTable.setSystemOrComponent(table.Rows[0].Cells[0].Paragraphs[0].Text);
     if (table.Rows[0].Cells.Count == 4)
     {
         for (int i = 1; i < table.Rows.Count; i++)
         {
             processRowFourCols(table.Rows[i]);
         }
     }
     else if (table.Rows[0].Cells.Count == 5)
     {
         for (int i = 1; i < table.Rows.Count; i++)
         {
             processRowFiveCols(table.Rows[i]);
         }
     }
 }
Пример #16
0
        private void FillAccounts(DocX doc)
        {
            LBCFUBL_WCF.DBO.Account[] accounts = Helper.GetAccountClient().GetAccountsForLogin(user.login);
            Novacode.Table            table    = doc.AddTable(accounts.Count() + 1, 2);
            setTableStyle(table);

            table.Rows[0].Cells[0].InsertParagraph().Bold().Append("Date");
            table.Rows[0].Cells[1].InsertParagraph().Bold().Append("Argent");

            int i = 1;

            foreach (LBCFUBL_WCF.DBO.Account account in accounts)
            {
                table.Rows[i].Cells[0].InsertParagraph().Append(account.date.ToString("dd-MM-yyyy hh:mm"));
                table.Rows[i].Cells[1].InsertParagraph().Append(account.argent.ToString("C", GetCurrencyFormat()));
                i++;
            }

            doc.InsertTable(table);
        }
Пример #17
0
 //Extracts the content of a Individual Table
 private void extractTableContent(Novacode.Table table)
 {
     scap.myTable.setSystemOrComponent(table.Rows[0].Cells[0].Paragraphs[0].Text);
     if (table.Rows[0].Cells.Count == 4)
     {
         for (int i = 1; i < table.Rows.Count; i++)
         {
             processRowFourCols(table.Rows[i]);
             //separateSystemsOrComponentsInTwoIfRequired();
         }
     }
     else if (table.Rows[0].Cells.Count == 5)
     {
         for (int i = 1; i < table.Rows.Count; i++)
         {
             processRowFiveCols(table.Rows[i]);
             //separateSystemsOrComponentsInTwoIfRequired();
         }
     }
 }
Пример #18
0
        private void FillPurchases(DocX doc)
        {
            LBCFUBL_WCF.DBO.Purchase[] purchases = Helper.GetPurchaseClient().GetPurchasesForLogin(user.login);
            Novacode.Table             table     = doc.AddTable(purchases.Count() + 1, 3);
            setTableStyle(table);

            table.Rows[0].Cells[0].InsertParagraph().Bold().Append("Date");
            table.Rows[0].Cells[1].InsertParagraph().Bold().Append("Produit");
            table.Rows[0].Cells[2].InsertParagraph().Bold().Append("Prix");

            int i = 1;

            foreach (LBCFUBL_WCF.DBO.Purchase purchase in purchases)
            {
                table.Rows[i].Cells[0].InsertParagraph().Append(purchase.date.ToString("dd-MM-yyyy hh:mm"));
                table.Rows[i].Cells[1].InsertParagraph().Append(purchase.Product.name);
                table.Rows[i].Cells[2].InsertParagraph().Append(purchase.Product.cost_with_margin.ToString("C", GetCurrencyFormat()));
                i++;
            }

            doc.InsertTable(table);
        }
Пример #19
0
        public Table InsertTable(Table t)
        {
            XElement newXElement = new XElement(t.Xml);
            Xml.Add(newXElement);

            Table newTable = new Table(Document, newXElement)
            {
                mainPart = mainPart,
                Design = t.Design
            };

            return newTable;
        }
Пример #20
0
 /// <summary>
 /// Insert a new Table after this Paragraph.
 /// </summary>
 /// <param name="t">The Table t to be inserted.</param>
 /// <returns>A new Table inserted after this Paragraph.</returns>
 /// <example>
 /// Insert a new Table after this Paragraph.
 /// <code>
 /// // Place holder for a Table.
 /// Table t;
 ///
 /// // Load document a.
 /// using (DocX documentA = DocX.Load(@"a.docx"))
 /// {
 ///     // Get the first Table from this document.
 ///     t = documentA.Tables[0];
 /// }
 ///
 /// // Load document b.
 /// using (DocX documentB = DocX.Load(@"b.docx"))
 /// {
 ///     // Get the first Paragraph in document b.
 ///     Paragraph p2 = documentB.Paragraphs[0];
 ///
 ///     // Insert the Table from document a after this Paragraph.
 ///     Table newTable = p2.InsertTableAfterSelf(t);
 ///
 ///     // Save all changes made to document b.
 ///     documentB.Save();
 /// }// Release this document from memory.
 /// </code>
 /// </example>
 public override Table InsertTableAfterSelf(Table t)
 {
     t = base.InsertTableAfterSelf(t);
     t.mainPart = mainPart;
     return t;
 }
Пример #21
0
 /// <summary>
 /// Insert a new Table after this Table, this Table can be from this document or another document.
 /// </summary>
 /// <param name="t">The Table t to be inserted</param>
 /// <returns>A new Table inserted after this Table.</returns>
 /// <example>
 /// Insert a new Table after this Table.
 /// <code>
 /// // Place holder for a Table.
 /// Table t;
 ///
 /// // Load document a.
 /// using (DocX documentA = DocX.Load(@"a.docx"))
 /// {
 ///     // Get the first Table from this document.
 ///     t = documentA.Tables[0];
 /// }
 ///
 /// // Load document b.
 /// using (DocX documentB = DocX.Load(@"b.docx"))
 /// {
 ///     // Get the first Table in document b.
 ///     Table t2 = documentB.Tables[0];
 ///
 ///     // Insert the Table from document a after this Table.
 ///     Table newTable = t2.InsertTableAfterSelf(t);
 ///
 ///     // Save all changes made to document b.
 ///     documentB.Save();
 /// }// Release this document from memory.
 /// </code>
 /// </example>
 public override Table InsertTableAfterSelf(Table t)
 {
     return base.InsertTableAfterSelf(t);
 }
Пример #22
0
        private static Table CreateAndInsertInvoiceTableAfter(Table t, ref DocX document)
        {
            // Grab data from somewhere (Most likely a database)
            DataTable data = GetDataFromDatabase();

            /*
             * The trick to replacing one Table with another,
             * is to insert the new Table after the old one,
             * and then remove the old one.
             */
            Table invoice_table = t.InsertTableAfterSelf(data.Rows.Count + 1, data.Columns.Count);
            invoice_table.Design = TableDesign.LightShadingAccent1;

            #region Table title
            Formatting table_title = new Formatting();
            table_title.Bold = true;

            invoice_table.Rows[0].Cells[0].Paragraphs[0].InsertText("Description", false, table_title);
            invoice_table.Rows[0].Cells[0].Paragraphs[0].Alignment = Alignment.center;
            invoice_table.Rows[0].Cells[1].Paragraphs[0].InsertText("Hours", false, table_title);
            invoice_table.Rows[0].Cells[1].Paragraphs[0].Alignment = Alignment.center;
            invoice_table.Rows[0].Cells[2].Paragraphs[0].InsertText("Rate", false, table_title);
            invoice_table.Rows[0].Cells[2].Paragraphs[0].Alignment = Alignment.center;
            invoice_table.Rows[0].Cells[3].Paragraphs[0].InsertText("Amount", false, table_title);
            invoice_table.Rows[0].Cells[3].Paragraphs[0].Alignment = Alignment.center;
            #endregion

            // Loop through the rows in the Table and insert data from the data source.
            for (int row = 1; row < invoice_table.RowCount; row++)
            {
                for (int cell = 0; cell < invoice_table.Rows[row].Cells.Count; cell++)
                {
                    Paragraph cell_paragraph = invoice_table.Rows[row].Cells[cell].Paragraphs[0];
                    cell_paragraph.InsertText(data.Rows[row - 1].ItemArray[cell].ToString(), false);
                }
            }

            // We want to fill in the total by suming the values from the amount column.
            Row total = invoice_table.InsertRow();
            total.Cells[0].Paragraphs[0].InsertText("Total:", false);
            Paragraph total_paragraph = total.Cells[invoice_table.ColumnCount - 1].Paragraphs[0];

            /*
             * Lots of people are scared of LINQ,
             * so I will walk you through this line by line.
             *
             * invoice_table.Rows is an IEnumerable<Row> (i.e a collection of rows), with LINQ you can query collections.
             * .Where(condition) is a filter that you want to apply to the items of this collection.
             * My condition is that the index of the row must be greater than 0 and less than RowCount.
             * .Select(something) lets you select something from each item in the filtered collection.
             * I am selecting the Text value from each row, for example €100, then I am remove the €,
             * and then I am parsing the remaining string as a double. This will return a collection of doubles,
             * the final thing I do is call .Sum() on this collection which return one double the sum of all the doubles,
             * this is the total.
             */
            double totalCost =
            (
                invoice_table.Rows
                .Where((row, index) => index > 0 && index < invoice_table.RowCount - 1)
                .Select(row => double.Parse(row.Cells[row.Cells.Count() - 1].Paragraphs[0].Text.Remove(0, 1)))
            ).Sum();

            // Insert the total calculated above using LINQ into the total Paragraph.
            total_paragraph.InsertText(string.Format("€{0}", totalCost), false);

            // Let the tables columns expand to fit its contents.
            invoice_table.AutoFit = AutoFit.Contents;

            // Center the Table
            invoice_table.Alignment = Alignment.center;

            // Return the invloce table now that it has been created.
            return invoice_table;
        }
Пример #23
0
 /// <summary>
 /// Insert a Table into this document. The Table's source can be a completely different document.
 /// </summary>
 /// <param name="t">The Table to insert.</param>
 /// <returns>The Table now associated with this document.</returns>
 /// <example>
 /// Extract a Table from document a and insert it at the end of document b.
 /// <code>
 /// // Place holder for a Table.
 /// Table t;
 ///
 /// // Load document a.
 /// using (DocX documentA = DocX.Load(@"C:\Example\a.docx"))
 /// {
 ///     // Get the first Table from this document.
 ///     t = documentA.Tables[0];
 /// }
 ///
 /// // Load document b.
 /// using (DocX documentB = DocX.Load(@"C:\Example\b.docx"))
 /// {
 ///     /* 
 ///      * Insert the Table that was extracted from document a, into document b. 
 ///      * This creates a new Table that is now associated with document b.
 ///      */
 ///     Table newTable = documentB.InsertTable(t);
 ///
 ///     // Save all changes made to document b.
 ///     documentB.Save();
 /// }// Release this document from memory.
 /// </code>
 /// </example>
 public new Table InsertTable(Table t)
 {
     t = base.InsertTable(t);
     t.mainPart = mainPart;
     return t;
 }
Пример #24
0
        public Table AddTable(int rowCount, int columnCount)
        {
            if (rowCount < 1 || columnCount < 1)
                throw new ArgumentOutOfRangeException("Row and Column count must be greater than zero.");

            Table t = new Table(this, HelperFunctions.CreateTable(rowCount, columnCount));
            t.mainPart = mainPart;
            return t;
        }
Пример #25
0
        /// <summary>
        /// Se utiliza para crear el CV que se carga a la BD.
        /// </summary>
        /// <param name="idCV"></param>
        /// <param name="rutaPlantilla"></param>
        /// <returns></returns>
        public MemoryStream CrearCurriculum(int idCV, string rutaPlantilla)
        {
            LNPlantillaCV lnPlantilla = new LNPlantillaCV();
            DataSet       Result      = lnPlantilla.ObtenerDatosParaPlantilla(idCV);

            System.Data.DataTable Person               = Result.Tables[0];
            System.Data.DataTable Education            = Result.Tables[1];
            System.Data.DataTable Experience           = Result.Tables[2];
            System.Data.DataTable AditionalInformation = Result.Tables[3];

            MemoryStream stream = new MemoryStream();

            Mustache mustache     = new Mustache();
            string   blockPattern = @"{{><model>}}";

            using (FileStream fileStream = System.IO.File.OpenRead(rutaPlantilla))
            {
                stream.SetLength(fileStream.Length);
                fileStream.Read(stream.GetBuffer(), 0, (int)fileStream.Length);
            }

            using (DocX doc = DocX.Load(stream))
            {
                dynamic template = new Template(rutaPlantilla)
                                   .Build()
                                   .Compile();

                #region person

                object person = new
                {
                    // Informacion basica
                    firstname        = Convert.ToString(Person.Rows[0]["Nombres"]).ToUpper(),
                    lastname         = Convert.ToString(Person.Rows[0]["Apellidos"]).ToUpper(),
                    document         = Convert.ToString(Person.Rows[0]["NumeroDocumento"]),
                    documentType     = Convert.ToString(Person.Rows[0]["TipoDocumento"]),
                    address          = Convert.ToString(Person.Rows[0]["Direccion"]),
                    district         = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(Convert.ToString(Person.Rows[0]["DireccionDistrito"])),
                    celphone         = Convert.ToString(Person.Rows[0]["TelefonoCelular"]),
                    email            = Convert.ToString(Person.Rows[0]["CorreoElectronico"]),
                    emailAlternative = Convert.ToString(Person.Rows[0]["CorreoElectronico2"]),
                    profile          = Convert.ToString(Person.Rows[0]["Perfil"]),
                    birthdate        = Convert.ToString(Person.Rows[0]["FechaNacimiento"])
                };

                if (Convert.ToBoolean(template.person.inlines.Count))
                {
                    foreach (string i in template.person.inlines)
                    {
                        doc.ReplaceText(i, mustache.Compile(i).Render(new { person = person }));
                    }
                }

                #endregion

                #region education

                object         education;
                string         educationPattern = blockPattern.Replace("<model>", "education");
                Novacode.Table educationWrapper;

                try
                {
                    educationWrapper = doc
                                       .Tables
                                       .Where(e => e.Paragraphs[0].Text.Contains(educationPattern))
                                       .ToList()[0];

                    // Clean reference template
                    educationWrapper.Rows[1].Remove();

                    foreach (DataRow data in Education.Rows)
                    {
                        educationWrapper.InsertTableAfterSelf(template.education.blocks[1]);

                        education = new
                        {
                            institute = Convert.ToString(data["Institucion"]),
                            study     = Convert.ToString(data["Estudio"]),
                            period    = ConvertirMes(Convert.ToInt32(data["FechaInicioMes"])) + Convert.ToString(data["FechaInicioAno"]).Substring(2, 2) +
                                        "-" + (data["FechaFinMes"] == DBNull.Value && data["FechaFinAno"] == DBNull.Value
                                    ? "Cont"
                                    : ConvertirMes(Convert.ToInt32(data["FechaFinMes"])) + Convert.ToString(data["FechaFinAno"]).Substring(2, 2))
                        };

                        foreach (string i in template.education.inlines)
                        {
                            doc.ReplaceText(i, mustache.Compile(i).Render(new { education = education }));
                        }
                    }

                    // Clean reference pointer
                    educationWrapper.Rows[0].Remove();
                }
                catch (Exception e) { }

                #endregion

                #region experience

                string         experiencePattern = blockPattern.Replace("<model>", "experience");
                Novacode.Table experienceWrapper;

                Dictionary <string, dynamic>        enterprises = new Dictionary <string, dynamic>();
                Dictionary <string, List <object> > experiences = new Dictionary <string, List <object> >();
                string[] enterpriseFields = new string[] { "Ciudad", "DescripcionEmpresa", "PaisDescripcion", "Empresa" };

                System.Data.DataTable Enterprises = Experience.DefaultView.ToTable(true, enterpriseFields);
                foreach (DataRow enterprise in Enterprises.Rows)
                {
                    List <object> aux = new List <object>();
                    int           timeOfExperience = 0;

                    System.Data.DataTable experiencesOfEnterprise = Experience.Select("Empresa = '" + Convert.ToString(enterprise["Empresa"]) + "'").CopyToDataTable();
                    foreach (DataRow data in experiencesOfEnterprise.Rows)
                    {
                        string period      = String.Empty;
                        string periodStart = String.Empty;
                        string periodEnd   = String.Empty;

                        periodStart = ConvertirMes(Convert.ToInt32(data["FechaInicioCargoMes"])) +
                                      Convert.ToString(data["FechaInicioCargoAno"]).Substring(2, 2);

                        periodEnd = (data["FechaFinCargoMes"] == DBNull.Value && data["FechaFinCargoAno"] == DBNull.Value)
                            ? "Cont"
                            : ConvertirMes(Convert.ToInt32(data["FechaFinCargoMes"])) +
                                    Convert.ToString(data["FechaFinCargoAno"]).Substring(2, 2);

                        period = String.Format("{0}-{1}", periodStart, periodEnd);

                        aux.Add(new
                        {
                            period            = period,
                            office            = Convert.ToString(data["NombreCargo"]),
                            officeDescription = Convert.ToString(data["DescripcionCargo"])
                        });

                        int yearStart  = Convert.ToInt32(data["FechaInicioCargoAno"]);
                        int monthStart = Convert.ToInt32(data["FechaInicioCargoMes"]);
                        int yearEnd    = (data["FechaFinCargoAno"] == DBNull.Value)
                            ? DateTime.Now.Year
                            : Convert.ToInt32(data["FechaFinCargoAno"]);
                        int monthEnd = (data["FechaFinCargoMes"] == DBNull.Value)
                            ? DateTime.Now.Month
                            : Convert.ToInt32(data["FechaFinCargoMes"]);

                        timeOfExperience += (yearEnd - yearStart) * 12 + monthEnd + 1 - monthStart;
                    }

                    enterprises.Add(Convert.ToString(enterprise["Empresa"]), new
                    {
                        enterprise                 = Convert.ToString(enterprise["Empresa"]),
                        enterpriseDescription      = Convert.ToString(enterprise["DescripcionEmpresa"]),
                        enterpriseTimeOfExperience = String.Format("({0} años, {1} meses)", Math.Truncate(timeOfExperience / 12.0), timeOfExperience % 12),
                        enterpriseCountry          = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(Convert.ToString(enterprise["PaisDescripcion"])),
                        enterpriseCity             = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(Convert.ToString(enterprise["Ciudad"]))
                    });
                    experiences.Add(Convert.ToString(enterprise["Empresa"]), aux);
                }

                try
                {
                    experienceWrapper = doc
                                        .Tables
                                        .Where(e => e.Paragraphs[0].Text.Contains(experiencePattern))
                                        .ToList()[0];

                    // Clean reference template
                    experienceWrapper.Rows[1].Remove();

                    foreach (var data in enterprises)
                    {
                        Novacode.Table enterpriseWrapper = experienceWrapper.InsertTableAfterSelf(template.experience.blocks[1]);

                        // Render enterprise info
                        for (int i = 0; i < enterpriseFields.Count() + 1; i++)
                        {
                            doc.ReplaceText(
                                template.experience.inlines[i],
                                mustache
                                .Compile(template.experience.inlines[i])
                                .Render(new
                            {
                                experience = enterprises[data.Key]
                            })
                                );
                        }

                        Novacode.Table enterpriseExperienceWrapper = enterpriseWrapper.Rows[1].Tables[0];
                        foreach (object experience in experiences[data.Key])
                        {
                            enterpriseExperienceWrapper.InsertTableAfterSelf(template.experience.blocks[2]);

                            foreach (string i in template.experience.inlines)
                            {
                                doc.ReplaceText(i, mustache.Compile(i).Render(new { experience = experience }));
                            }
                        }

                        enterpriseExperienceWrapper.Rows[0].Remove();
                    }

                    // Clean reference pointer
                    experienceWrapper.Rows[0].Remove();
                }
                catch (Exception e) { }

                #endregion

                #region aditional information

                object         aditionalInformation;
                string         aditionalInformationPattern = blockPattern.Replace("<model>", "aditionalInformation");
                Novacode.Table aditionalInformationWrapper;

                try
                {
                    aditionalInformationWrapper = doc
                                                  .Tables
                                                  .Where(e => e.Paragraphs[0].Text.Contains(aditionalInformationPattern))
                                                  .ToList()[0];

                    // Clean reference template
                    aditionalInformationWrapper.Rows[1].Remove();

                    foreach (DataRow data in AditionalInformation.Rows)
                    {
                        aditionalInformationWrapper.InsertTableAfterSelf(template.aditionalInformation.blocks[1]);

                        aditionalInformation = new
                        {
                            knowledge = Convert.ToString(data["Conocimiento"]),
                            level     = Convert.ToString(data["NivelConocimientoDescripcion"]),
                            institute = Convert.ToString(data["InstituciónDeEstudio"]),
                            date      = Convert.ToString(data["FechaConocimientoHastaAno"])
                        };

                        foreach (string i in template.aditionalInformation.inlines)
                        {
                            doc.ReplaceText(i, mustache.Compile(i).Render(new { aditionalInformation = aditionalInformation }));
                        }
                    }

                    // Clean reference pointer
                    aditionalInformationWrapper.Rows[0].Remove();
                }
                catch (Exception e) { }

                #endregion

                doc.Save();
            }

            return(stream);
        }
Пример #26
0
        private void TablazatFormazas( Table table ) {
            table.AutoFit = AutoFit.ColumnWidth;
            for( int i = 0; i < table.Rows.Count; i++ ) {
                table.Rows[i].Cells[0].Width = 30;
                table.Rows[i].Cells[1].Width = 50;
                table.Rows[i].Cells[2].Width = 200;
                table.Rows[i].Cells[3].Width = 50;
                table.Rows[i].Cells[4].Width = 200;
                table.Rows[i].Cells[5].Width = 70;
                table.Rows[i].Cells[6].Width = 70;
            }

            Border c = new Border(Novacode.BorderStyle.Tcbs_none,BorderSize.seven, 0, Color.Black);
            Border d = new Border(Novacode.BorderStyle.Tcbs_single,BorderSize.five, 0, Color.Black);

            //table.SetBorder( TableBorderType.InsideH, d );
            //table.SetBorder( TableBorderType.InsideV, c );
            //table.SetBorder( TableBorderType.Bottom, c );
            //table.SetBorder( TableBorderType.Top, c );
            //table.SetBorder( TableBorderType.Left, c );
            //table.SetBorder( TableBorderType.Right, c );
        }
Пример #27
0
        public static void createWorksWithCarDocument(order o)
        {
            var doc = DocX.Create("WorksWithCar" + ".docx");

            doc.PageLayout.Orientation = Novacode.Orientation.Landscape;

            doc.MarginLeft = 40;
            doc.MarginTop  = 10;

            //СЧ|ГЛ
            Novacode.Table table1 = doc.AddTable(1, 2);
            table1.AutoFit   = AutoFit.Contents;
            table1.Alignment = Alignment.center;
            table1.Rows[0].Cells[0].Paragraphs.First().InsertText("СЧ", false, new Formatting {
                FontFamily = new System.Drawing.FontFamily("Times New Roman"), Size = 12
            });
            table1.Rows[0].Cells[1].Paragraphs.First().InsertText("ГЛ", false, new Formatting {
                FontFamily = new System.Drawing.FontFamily("Times New Roman"), Size = 12
            });
            doc.InsertTable(table1);

            //Час и дата получения и здачі авто
            Novacode.Table table2 = doc.AddTable(1, 2);
            table2.AutoFit   = AutoFit.Window;
            table2.Alignment = Alignment.center;
            table2.Design    = Novacode.TableDesign.TableNormal;

            table2.Rows[0].Cells[0].Paragraphs.First().InsertText("Мережа майстерень кузовного ремонту «PS»", false, new Formatting {
                FontFamily = new FontFamily("Times New Roman"), Bold = true, Size = 16
            });
            table2.Rows[0].Cells[0].InsertParagraph("\nЗАКАЗ – НАРЯД  № ", false, new Formatting {
                FontFamily = new FontFamily("Times New Roman"), Size = 12
            });
            table2.Rows[0].Cells[0].Paragraphs[1].InsertText(o.idOrder.ToString(), false, new Formatting {
                FontFamily = new FontFamily("Times New Roman"), Bold = true, Italic = true, Size = 14
            });

            table2.Rows[0].Cells[0].Paragraphs[1].InsertText("\nПІБ клієнта ", false, new Formatting {
                FontFamily = new FontFamily("Times New Roman"), Size = 12
            });
            table2.Rows[0].Cells[0].Paragraphs[1].InsertText(getFIOClient(o.Car_idCar), false, new Formatting {
                FontFamily = new FontFamily("Times New Roman"), Bold = true, Italic = true, Size = 14
            });

            table2.Rows[0].Cells[0].Paragraphs[1].Alignment = Alignment.left;
            table2.Rows[0].Cells[1].Paragraphs.First().InsertTableBeforeSelf(5, 4);
            table2.Rows[0].Cells[1].Tables.First().AutoFit = AutoFit.Contents;
            table2.Rows[0].Cells[1].Tables.First().Rows[0].Cells[0].Paragraphs.First().InsertText("Дата прийому авто від клієнта", false, new Formatting {
                FontFamily = new FontFamily("Times New Roman"), Size = 10
            });
            table2.Rows[0].Cells[1].Tables.First().Rows[0].Cells[1].Paragraphs.First().InsertText(o.dateTime.Value.ToString().Split(' ')[0], false, new Formatting {
                FontFamily = new FontFamily("Times New Roman"), Size = 10
            });
            table2.Rows[0].Cells[1].Tables.First().Rows[0].Cells[2].Paragraphs.First().InsertText("Час прийому авто від клієнта", false, new Formatting {
                FontFamily = new FontFamily("Times New Roman"), Size = 10
            });
            table2.Rows[0].Cells[1].Tables.First().Rows[0].Cells[3].Paragraphs.First().InsertText(o.dateTime.Value.ToString().Split(' ')[1], false, new Formatting {
                FontFamily = new FontFamily("Times New Roman"), Size = 10
            });

            table2.Rows[0].Cells[1].Tables.First().Rows[1].Cells[0].Paragraphs.First().InsertText("Дата і Час - авто в цеху\n(ставить НЧ)", false, new Formatting {
                FontFamily = new FontFamily("Times New Roman"), Bold = true, Size = 10
            });
            table2.Rows[0].Cells[1].Tables.First().Rows[1].Cells[2].Paragraphs.First().InsertText("Дата і Час завершення  цех\n(ставить НЧ)", false, new Formatting {
                FontFamily = new FontFamily("Times New Roman"), Bold = true, Size = 10
            });
            table2.Rows[0].Cells[1].Tables.First().Rows[3].Cells[0].Paragraphs.First().InsertText("Дата здачі авто клієнту", false, new Formatting {
                FontFamily = new FontFamily("Times New Roman"), Size = 10
            });
            table2.Rows[0].Cells[1].Tables.First().Rows[3].Cells[2].Paragraphs.First().InsertText("Час здачі авто клієнту", false, new Formatting {
                FontFamily = new FontFamily("Times New Roman"), Size = 10
            });

            table2.Rows[0].Cells[1].Tables.First().Rows[4].Cells[0].Paragraphs.First().InsertText("Дата і Час – авто в цеху: ", false, new Formatting {
                FontFamily = new FontFamily("Times New Roman"), Italic = true, Bold = true, Size = 10
            });
            table2.Rows[0].Cells[1].Tables.First().Rows[4].Cells[0].Paragraphs.First().InsertText("автомобіль пригнано  в цех. Ставить НЧ.\n", false, new Formatting {
                FontFamily = new FontFamily("Times New Roman"), Italic = true, Size = 10
            });
            table2.Rows[0].Cells[1].Tables.First().Rows[4].Cells[0].Paragraphs.First().InsertText("Дата і Час завершення цех ", false, new Formatting {
                FontFamily = new FontFamily("Times New Roman"), Italic = true, Bold = true, Size = 10
            });
            table2.Rows[0].Cells[1].Tables.First().Rows[4].Cells[0].Paragraphs.First().InsertText("–роботи завершені по авто в цеху. Ставить НЧ.", false, new Formatting {
                FontFamily = new FontFamily("Times New Roman"), Italic = true, Size = 10
            });
            table2.Rows[0].Cells[1].Tables.First().Rows[4].MergeCells(0, table2.Rows[0].Cells[1].Tables.First().ColumnCount - 1);

            for (int i = 0; i < 3; i++)
            {
                table2.Rows[0].Cells[1].Tables.First().Rows[4].Cells[0].RemoveParagraph(table2.Rows[0].Cells[1].Tables.First().Rows[4].Cells[0].Paragraphs[1]);
            }

            table2.Rows[0].Cells[1].Tables.First().Rows[4].Cells[0].Paragraphs.First().Alignment = Alignment.center;

            table2.Rows[0].Cells[1].Tables.First().MergeCellsInColumn(0, 1, 2);
            table2.Rows[0].Cells[1].Tables.First().MergeCellsInColumn(2, 1, 2);
            table2.Rows[0].Cells[1].Tables.First().Rows[1].Cells[1].FillColor = Color.WhiteSmoke;
            table2.Rows[0].Cells[1].Tables.First().Rows[2].Cells[1].FillColor = Color.WhiteSmoke;
            table2.Rows[0].Cells[1].Tables.First().Rows[1].Cells[3].FillColor = Color.WhiteSmoke;
            table2.Rows[0].Cells[1].Tables.First().Rows[2].Cells[3].FillColor = Color.WhiteSmoke;


            doc.InsertTable(table2);
            doc.InsertParagraph("");

            //Информация о авто
            Novacode.Table table3 = doc.AddTable(2, 21);
            table3.AutoFit   = AutoFit.Contents;
            table3.Alignment = Alignment.left;

            table3.Rows[0].Cells[0].Paragraphs.First().InsertText("Марка, модель", false, new Formatting {
                FontFamily = new FontFamily("Times New Roman"), Size = 10
            });
            table3.Rows[0].Cells[1].Paragraphs.First().InsertText(getMarkaModelCar(o.Car_idCar), false, new Formatting {
                FontFamily = new FontFamily("Times New Roman"), Italic = true, Bold = true, Size = 12
            });
            table3.Rows[1].Cells[0].Paragraphs.First().InsertText("Рік випуску", false, new Formatting {
                FontFamily = new FontFamily("Times New Roman"), Size = 10
            });
            table3.Rows[1].Cells[1].Paragraphs.First().InsertText(getYearOld(o.Car_idCar), false, new Formatting {
                FontFamily = new FontFamily("Times New Roman"), Size = 10
            });
            table3.Rows[0].Cells[2].Paragraphs.First().InsertText("Держ. реєс.номер", false, new Formatting {
                FontFamily = new FontFamily("Times New Roman"), Size = 10
            });
            table3.Rows[0].Cells[3].Paragraphs.First().InsertText(getRegNumber(o.Car_idCar), false, new Formatting {
                FontFamily = new FontFamily("Times New Roman"), Size = 12, Bold = true
            });
            table3.Rows[1].Cells[2].Paragraphs.First().InsertText("VIN код кузова", false, new Formatting {
                FontFamily = new FontFamily("Times New Roman"), Size = 10
            });

            for (int i = 0; i < 17; i++)
            {
                string vincode = getVinCode(o.Car_idCar);
                table3.Rows[1].Cells[3 + i].Paragraphs.First().InsertText(vincode[i].ToString(), false, new Formatting {
                    FontFamily = new FontFamily("Times New Roman"), Size = 10, Bold = true, Italic = true
                });
            }
            table3.Rows[0].MergeCells(3, 19);
            for (int i = 0; i < 16; i++)
            {
                table3.Rows[0].Cells[3].RemoveParagraph(table3.Rows[0].Cells[3].Paragraphs[1]);
            }

            table3.Rows[0].Cells[4].Paragraphs.First().InsertText("Пробіг", false, new Formatting {
                FontFamily = new FontFamily("Times New Roman"), Size = 10
            });
            table3.Rows[1].Cells[20].Paragraphs.First().InsertText(getDistance(o.Car_idCar), false, new Formatting {
                FontFamily = new FontFamily("Times New Roman"), Size = 10
            });

            table3.Rows[0].Cells[0].Width     = 120;// new List<double> { 30, 30, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 30 };
            table3.Rows[0].Cells[2].Width     = 120;
            table3.Rows[0].Cells[4].Width     = 120;
            table3.Rows[0].Cells[1].FillColor = Color.WhiteSmoke;
            table3.Rows[0].Cells[3].FillColor = Color.WhiteSmoke;
            table3.Rows[1].Cells[table3.Rows[1].Cells.Count - 1].FillColor = Color.WhiteSmoke;
            doc.InsertTable(table3);

            doc.InsertParagraph("роботи: ", false, new Formatting {
                FontFamily = new FontFamily("Times New Roman"), Size = 12
            });

            List <WorkClass> worksList = getWorksList(o.idOrder);

            Novacode.Table table4 = doc.AddTable(worksList.Count + 1, 12);
            table4.Alignment = Alignment.left;

            Formatting f = new Formatting();

            f.FontFamily = new FontFamily("Times New Roman");
            f.Size       = 10;

            table4.Rows[0].Cells[0].Paragraphs.First().InsertText("Код", false, f);
            table4.Rows[0].Cells[0].Width = 30;
            table4.Rows[0].Cells[1].Paragraphs.First().InsertText("Назва робіт", false, f);
            table4.Rows[0].Cells[1].Width = 350;
            table4.Rows[0].Cells[2].Paragraphs.First().InsertText("Початок\n(по плану)\nДата\tЧас", false, f);
            table4.Rows[0].MergeCells(2, 3);
            table4.Rows[0].RemoveParagraph(table4.Rows[0].Cells[2].Paragraphs[1]);
            table4.Rows[0].Cells[2].Width = 200;
            table4.Rows[0].Cells[3].Paragraphs.First().InsertText("Кінець\n(по плану)\nДата\tЧас", false, f);
            table4.Rows[0].MergeCells(3, 4);
            table4.Rows[0].RemoveParagraph(table4.Rows[0].Cells[3].Paragraphs[1]);
            table4.Rows[0].Cells[3].Width = 200;
            table4.Rows[0].Cells[4].Paragraphs.First().InsertText("Початок\n(по факту)\nДата\tЧас", false, f);
            table4.Rows[0].MergeCells(4, 5);
            table4.Rows[0].RemoveParagraph(table4.Rows[0].Cells[4].Paragraphs[1]);
            table4.Rows[0].Cells[4].Width = 200;
            table4.Rows[0].Cells[5].Paragraphs.First().InsertText("Кінець\n(по факту)\nДата\tЧас", false, f);
            table4.Rows[0].MergeCells(5, 6);
            table4.Rows[0].RemoveParagraph(table4.Rows[0].Cells[5].Paragraphs[1]);
            table4.Rows[0].Cells[5].Width = 200;
            table4.Rows[0].Cells[6].Paragraphs.First().InsertText("Виконавець", false, f);
            table4.Rows[0].Cells[6].Width = 150;
            table4.Rows[0].Cells[7].Paragraphs.First().InsertText("Стан", false, f);
            table4.Rows[0].Cells[7].Width = 100;
            foreach (Cell c in table4.Rows[0].Cells)
            {
                c.Paragraphs.First().Alignment = Alignment.center;
            }
            int nunmberRow = 1;

            foreach (WorkClass wc in worksList)
            {
                table4.Rows[nunmberRow].Cells[0].Paragraphs.First().InsertText(wc.Id.ToString(), false, f);

                table4.Rows[nunmberRow].Cells[1].Paragraphs.First().InsertText(wc.NameOperation, false, f);

                table4.Rows[nunmberRow].Cells[2].Paragraphs.First().InsertText(wc.StartPlan.Split(' ')[0], false, f);
                table4.Rows[nunmberRow].Cells[3].Paragraphs.First().InsertText(wc.StartPlan.Split(' ')[1], false, f);

                table4.Rows[nunmberRow].Cells[4].Paragraphs.First().InsertText(wc.FinishPlan.Split(' ')[0], false, f);
                table4.Rows[nunmberRow].Cells[5].Paragraphs.First().InsertText(wc.FinishPlan.Split(' ')[1], false, f);

                if (wc.StartFact != "")
                {
                    table4.Rows[nunmberRow].Cells[6].Paragraphs.First().InsertText(wc.StartFact.Split(' ')[0], false, f);
                    table4.Rows[nunmberRow].Cells[7].Paragraphs.First().InsertText(wc.StartFact.Split(' ')[1], false, f);
                }

                if (wc.FinishFact != "")
                {
                    table4.Rows[nunmberRow].Cells[8].Paragraphs.First().InsertText(wc.FinishFact.Split(' ')[0], false, f);
                    table4.Rows[nunmberRow].Cells[9].Paragraphs.First().InsertText(wc.FinishFact.Split(' ')[1], false, f);
                }

                table4.Rows[nunmberRow].Cells[10].Paragraphs.First().InsertText(wc.NameWorker, false, f);
                table4.Rows[nunmberRow].Cells[11].Paragraphs.First().InsertText(wc.Condition, false, f);

                nunmberRow++;
            }
            doc.InsertTable(table4);

            doc.Save();
            ViewModels.ClassForAudio.playScan();
        }
Пример #28
0
        /// <summary>
        /// Insert a new Table before this Table, this Table can be from this document or another document.
        /// </summary>
        /// <param name="t">The Table t to be inserted</param>
        /// <returns>A new Table inserted before this Table.</returns>
        /// <example>
        /// Insert a new Table before this Table.
        /// <code>
        /// // Place holder for a Table.
        /// Table t;
        ///
        /// // Load document a.
        /// using (DocX documentA = DocX.Load(@"a.docx"))
        /// {
        ///     // Get the first Table from this document.
        ///     t = documentA.Tables[0];
        /// }
        ///
        /// // Load document b.
        /// using (DocX documentB = DocX.Load(@"b.docx"))
        /// {
        ///     // Get the first Table in document b.
        ///     Table t2 = documentB.Tables[0];
        ///
        ///     // Insert the Table from document a before this Table.
        ///     Table newTable = t2.InsertTableBeforeSelf(t);
        ///
        ///     // Save all changes made to document b.
        ///     documentB.Save();
        /// }// Release this document from memory.
        /// </code>
        /// </example>
        public Table InsertTableBeforeSelf(Table t)
        {
            xml.AddBeforeSelf(t.xml);
            XElement newlyInserted = xml.ElementsBeforeSelf().First();

            t.xml = newlyInserted;
            DocX.RebuildTables(document);
            DocX.RebuildParagraphs(document);

            return t;
        }
Пример #29
0
        KonszignacioDataTableFormazas( Table _table )
        {
            _table.AutoFit = AutoFit.Contents;
            Border c = new Border( BorderStyle.Tcbs_none, BorderSize.two, 0, Color.Black );
            _table.SetBorder( TableBorderType.InsideH, c );
            _table.SetBorder( TableBorderType.InsideV, c );
            _table.SetBorder( TableBorderType.Bottom, c );
            _table.SetBorder( TableBorderType.Top, c );
            _table.SetBorder( TableBorderType.Left, c );
            _table.SetBorder( TableBorderType.Right, c );

            for ( int i = 0 ; i < _table.Rows[ 0 ].Cells.Count ; i++ )
            {
                _table.Rows[ 0 ].Cells[ i ].SetBorder( TableCellBorderType.Top, new Border( BorderStyle.Tcbs_single, BorderSize.six, 0, Color.Black ) );
                _table.Rows[ 0 ].Cells[ i ].SetBorder( TableCellBorderType.Bottom, new Border( BorderStyle.Tcbs_single, BorderSize.six, 0, Color.Black ) );
            }
            for ( int i = 0 ; i < _table.Rows.Count ; i++ )
            {
                if ( _table.Rows[ i ].Cells[ 1 ].Paragraphs[ 0 ].Text.Contains( "összesen" ) )
                {
                    for ( int j = 0 ;
                         j < _table.Rows[ i ].Cells.Count ;
                         j++ )
                    {
                        _table.Rows[ i ].Cells[ j ].SetBorder( TableCellBorderType.Top, new Border( BorderStyle.Tcbs_single,
                                                                                       BorderSize.six, 0, Color.Black ) );
                    }
                }
                else if ( _table.Rows[ i ].Cells[ 1 ].Paragraphs[ 0 ].Text.Contains( "elszállítás" ) )
                {
                    for ( int j = 0 ;
                         j < _table.Rows[ i ].Cells.Count ;
                         j++ )
                    {
                        _table.Rows[ i ].Cells[ j ].SetBorder( TableCellBorderType.Top, new Border( BorderStyle.Tcbs_single,
                                                                                               BorderSize.six, 0, Color.Black ) );
                        _table.Rows[ i ].Cells[ j ].SetBorder( TableCellBorderType.Bottom, new Border( BorderStyle.Tcbs_single,
                                                                                                BorderSize.six, 0, Color.Black ) );
                    }
                    _table.Rows[ i ].Cells[ 0 ].SetBorder( TableCellBorderType.Left, new Border( BorderStyle.Tcbs_single,
                                                                                            BorderSize.six, 0, Color.Black ) );
                    _table.Rows[ i ].Cells[ 6 ].SetBorder( TableCellBorderType.Right, new Border( BorderStyle.Tcbs_single,
                                                                                            BorderSize.six, 0, Color.Black ) );
                }
            }

            //konszig táblázat-BN
            _table.AutoFit = AutoFit.ColumnWidth;

            for ( int i = 0 ; i < _table.Rows.Count ; i++ )
            {
                _table.Rows[ i ].Cells[ 0 ].Width = 45;     //sorszám
                _table.Rows[ i ].Cells[ 1 ].Width = 210;    //megnevezés
                _table.Rows[ i ].Cells[ 2 ].Width = 60;     //hordó
                _table.Rows[ i ].Cells[ 3 ].Width = 50;     //sarzs
                _table.Rows[ i ].Cells[ 4 ].Width = 80;     //súly
                _table.Rows[ i ].Cells[ 5 ].Width = 160;    //h.típus
                _table.Rows[ i ].Cells[ 6 ].Width = 110;    //dátum
            }
            _table.AutoFit = AutoFit.ColumnWidth;
        }
Пример #30
0
        KonszignacioFejlecTablazatFormazas( Table _table )
        {
            Border c = new Border( BorderStyle.Tcbs_none, BorderSize.seven, 0, Color.Black );
            _table.SetBorder( TableBorderType.InsideH, c );
            _table.SetBorder( TableBorderType.InsideV, c );
            _table.SetBorder( TableBorderType.Bottom, c );
            _table.SetBorder( TableBorderType.Top, c );
            _table.SetBorder( TableBorderType.Left, c );
            _table.SetBorder( TableBorderType.Right, c );

            //konszig táblázat fejléc-BN
            _table.AutoFit = AutoFit.ColumnWidth;

            for ( int i = 0 ; i < _table.Rows.Count ; i++ )
            {
                _table.Rows[ i ].Cells[ 0 ].Width = 80;         //vevő fix
                _table.Rows[ i ].Cells[ 1 ].Width = 300;        //vevő
                _table.Rows[ i ].Cells[ 2 ].Width = 60;         //feladó fix
                _table.Rows[ i ].Cells[ 3 ].Width = 300;        //feladó
            }
            _table.AutoFit = AutoFit.ColumnWidth;
        }
Пример #31
0
        MinBizDataTablazatFormazasa( Table _table )
        {
            _table.AutoFit = AutoFit.Contents;

            Border c = new Border( BorderStyle.Tcbs_none, BorderSize.seven, 0, Color.Black );
            _table.SetBorder( TableBorderType.InsideH, c );
            _table.SetBorder( TableBorderType.InsideV, c );
            _table.SetBorder( TableBorderType.Bottom, c );
            _table.SetBorder( TableBorderType.Top, c );
            _table.SetBorder( TableBorderType.Left, c );
            _table.SetBorder( TableBorderType.Right, c );
        }
Пример #32
0
        MinBizDataTable( MINOSEGBIZONYLAT _data, KONSZIGNACIOSZALLITOLEVEL _szállítólevél, int i, Table table )
        {
            int c;
            if ( _szállítólevél.Nyelv == "M" )
            {
                #region fixstring
                c = -1;
                table.Rows[ ++c ].Cells[ 0 ].Paragraphs[ 0 ].Append( "Szállítólevél szám:" ).Bold( );
                table.Rows[ ++c ].Cells[ 0 ].Paragraphs[ 0 ].Append( "Vevő megnevezése:" ).Bold( );
                table.Rows[ ++c ].Cells[ 0 ].Paragraphs[ 0 ].Append( "Megnevezés:" ).Bold( );
                table.Rows[ ++c ].Cells[ 0 ].Paragraphs[ 0 ].Append( "Gyártási idő:" ).Bold( );
                table.Rows[ ++c ].Cells[ 0 ].Paragraphs[ 0 ].Append( "Sarzs:" ).Bold( );
                table.Rows[ ++c ].Cells[ 0 ].Paragraphs[ 0 ].Append( "Szín:" ).Bold( );
                table.Rows[ ++c ].Cells[ 0 ].Paragraphs[ 0 ].Append( "Íz:" ).Bold( );
                table.Rows[ ++c ].Cells[ 0 ].Paragraphs[ 0 ].Append( "Illat:" ).Bold( );
                table.Rows[ ++c ].Cells[ 0 ].Paragraphs[ 0 ].Append( "Brix:" ).Bold( );
                table.Rows[ ++c ].Cells[ 0 ].Paragraphs[ 0 ].Append( "Savtartalom (citromsavban):" ).Bold( );
                table.Rows[ ++c ].Cells[ 0 ].Paragraphs[ 0 ].Append( "pH:" ).Bold( );
                table.Rows[ ++c ].Cells[ 0 ].Paragraphs[ 0 ].Append( "Konzisztencia (Bostwick fok):" ).Bold( );
                table.Rows[ ++c ].Cells[ 0 ].Paragraphs[ 0 ].Append( "Hozzáadott citromsav:" ).Bold( );
                table.Rows[ ++c ].Cells[ 0 ].Paragraphs[ 0 ].Append( "Hozzáadott cukor:" ).Bold( );
                table.Rows[ ++c ].Cells[ 0 ].Paragraphs[ 0 ].Append( "Aszkorbinsav:" ).Bold( );
                table.Rows[ ++c ].Cells[ 0 ].Paragraphs[ 0 ].Append( "Hozzáadott színezék:" ).Bold( );
                table.Rows[ ++c ].Cells[ 0 ].Paragraphs[ 0 ].Append( "Hozzáadott aroma:" ).Bold( );
                table.Rows[ ++c ].Cells[ 0 ].Paragraphs[ 0 ].Append( "Hozzáadott tartósítószer:" ).Bold( );
                table.Rows[ ++c ].Cells[ 0 ].Paragraphs[ 0 ].Append( "Átlagos tápérték tartalom 100 g termékben" ).Bold( );
                table.Rows[ ++c ].Cells[ 0 ].Paragraphs[ 0 ].Append( "     Energia tartalom:" ).Bold( );
                table.Rows[ ++c ].Cells[ 0 ].Paragraphs[ 0 ].Append( "     Fehérje:" ).Bold( );
                table.Rows[ ++c ].Cells[ 0 ].Paragraphs[ 0 ].Append( "     Szénhidrát:" ).Bold( );
                table.Rows[ ++c ].Cells[ 0 ].Paragraphs[ 0 ].Append( "     Zsír:" ).Bold( );
                table.Rows[ ++c ].Cells[ 0 ].Paragraphs[ 0 ].Append( "     Élelmi rost:" ).Bold( );
                table.Rows[ ++c ].Cells[ 0 ].Paragraphs[ 0 ].Append( "Mikrobiológia:" ).Bold( );
                table.Rows[ ++c ].Cells[ 0 ].Paragraphs[ 0 ].Append( "Minőségét megőrzi:" ).Bold( );
                table.Rows[ ++c ].Cells[ 0 ].Paragraphs[ 0 ].Append( "Passzírozottság:" ).Bold( );
                table.Rows[ ++c ].Cells[ 0 ].Paragraphs[ 0 ].Append( "Nettó tömeg:" ).Bold( );
                table.Rows[ ++c ].Cells[ 0 ].Paragraphs[ 0 ].Append( "Tárolás:" ).Bold( );
                table.Rows[ ++c ].Cells[ 0 ].Paragraphs[ 0 ].Append( "Csomagolás:" ).Bold( );
                table.Rows[ ++c ].Cells[ 0 ].Paragraphs[ 0 ].Append( "Származási hely:" ).Bold( );
                #endregion

                #region data
                c = -1;
                table.Rows[ ++c ].Cells[ 1 ].Paragraphs[ 0 ].Append( _szállítólevél.Szallitolevel ).Bold( );
                table.Rows[ ++c ].Cells[ 1 ].Paragraphs[ 0 ].Append( _data.szallitolevel.Vevo ).Bold( );
                table.Rows[ ++c ].Cells[ 1 ].Paragraphs[ 0 ].Append( _data.vizsgalatilap.Megnevezes ).Bold( );
                table.Rows[ ++c ].Cells[ 1 ].Paragraphs[ 0 ].Append( _data.szallitolevel.GyartasiIdo.Substring( 0, 4 ) + ". évben" ).Bold( );
                table.Rows[ ++c ].Cells[ 1 ].Paragraphs[ 0 ].Append( _data.vizsgalatilap.Sarzs ).Bold( );
                table.Rows[ ++c ].Cells[ 1 ].Paragraphs[ 0 ].Append( _data.szallitolevel.Szin );
                table.Rows[ ++c ].Cells[ 1 ].Paragraphs[ 0 ].Append( _data.szallitolevel.Iz );
                table.Rows[ ++c ].Cells[ 1 ].Paragraphs[ 0 ].Append( _data.szallitolevel.Illat );
                table.Rows[ ++c ].Cells[ 1 ].Paragraphs[ 0 ].Append( MinMax( _data.vizsgalatilap.Brix ) + " %" );
                table.Rows[ ++c ].Cells[ 1 ].Paragraphs[ 0 ].Append( MinMax( _data.vizsgalatilap.Citromsav ) + " %" );
                table.Rows[ ++c ].Cells[ 1 ].Paragraphs[ 0 ].Append( MinMax( _data.vizsgalatilap.Ph ) );
                table.Rows[ ++c ].Cells[ 1 ].Paragraphs[ 0 ].Append( MinMax( _data.vizsgalatilap.Bostwick ) + " cm/30 sec" );
                if ( _data.vizsgalatilap.CitromsavAdagolas.min == 0 && _data.vizsgalatilap.CitromsavAdagolas.max == 0 ) { table.Rows[ ++c ].Cells[ 1 ].Paragraphs[ 0 ].Append( "nincs" ); }
                else { table.Rows[ ++c ].Cells[ 1 ].Paragraphs[ 0 ].Append( MinMax( _data.vizsgalatilap.CitromsavAdagolas ) ); }
                table.Rows[ ++c ].Cells[ 1 ].Paragraphs[ 0 ].Append( _data.fixstring.Cukor );
                table.Rows[ ++c ].Cells[ 1 ].Paragraphs[ 0 ].Append( "maximum " + _data.vizsgalatilap.Aszkorbinsav + " mg/kg" );
                table.Rows[ ++c ].Cells[ 1 ].Paragraphs[ 0 ].Append( _data.fixstring.Szinezek );
                table.Rows[ ++c ].Cells[ 1 ].Paragraphs[ 0 ].Append( _data.fixstring.Aroma );
                table.Rows[ ++c ].Cells[ 1 ].Paragraphs[ 0 ].Append( _data.fixstring.Aroma );
                table.Rows[ ++c ].Cells[ 1 ].Paragraphs[ 0 ].Append( "" );
                table.Rows[ ++c ].Cells[ 1 ].Paragraphs[ 0 ].Append( _data.tapertek.EnergiaTartalom1 + " kj / " + _data.tapertek.EnergiaTartalom2 + " kcal" );
                table.Rows[ ++c ].Cells[ 1 ].Paragraphs[ 0 ].Append( _data.tapertek.Feherje + " g" );
                table.Rows[ ++c ].Cells[ 1 ].Paragraphs[ 0 ].Append( _data.tapertek.Szenhidrat + " g" );
                table.Rows[ ++c ].Cells[ 1 ].Paragraphs[ 0 ].Append( _data.tapertek.Zsir + " g" );
                table.Rows[ ++c ].Cells[ 1 ].Paragraphs[ 0 ].Append( _data.tapertek.Elelmirost + " g" );
                table.Rows[ ++c ].Cells[ 1 ].Paragraphs[ 0 ].Append( _data.fixstring.MikroBiologia );
                table.Rows[ ++c ].Cells[ 1 ].Paragraphs[ 0 ].Append( _data.fixstring.MinosegetMegorzi );
                table.Rows[ ++c ].Cells[ 1 ].Paragraphs[ 0 ].Append( _data.vizsgalatilap.Paszirozottsag + "-es szitán" );
                table.Rows[ ++c ].Cells[ 1 ].Paragraphs[ 0 ].Append( _data.fixstring.NettoTomeg );
                table.Rows[ ++c ].Cells[ 1 ].Paragraphs[ 0 ].Append( _data.fixstring.Tarolas );
                table.Rows[ ++c ].Cells[ 1 ].Paragraphs[ 0 ].Append( "aszeptikus zsákban és " + _data.vizsgalatilap.Csomagolas );
                table.Rows[ ++c ].Cells[ 1 ].Paragraphs[ 0 ].Append( _data.vizsgalatilap.SzarmazasiHely );
                #endregion
            }
            else
            {
                #region fixstring
                c = -1;
                table.Rows[ ++c ].Cells[ 0 ].Paragraphs[ 0 ].Append( "Customer name:" ).Bold( );
                table.Rows[ ++c ].Cells[ 0 ].Paragraphs[ 0 ].Append( "Product name:" ).Bold( );
                table.Rows[ ++c ].Cells[ 0 ].Paragraphs[ 0 ].Append( "Date of production:" ).Bold( );
                table.Rows[ ++c ].Cells[ 0 ].Paragraphs[ 0 ].Append( "Batch number:" ).Bold( );
                table.Rows[ ++c ].Cells[ 0 ].Paragraphs[ 0 ].Append( "Colour:" ).Bold( );
                table.Rows[ ++c ].Cells[ 0 ].Paragraphs[ 0 ].Append( "Taste:" ).Bold( );
                table.Rows[ ++c ].Cells[ 0 ].Paragraphs[ 0 ].Append( "Odour:" ).Bold( );
                table.Rows[ ++c ].Cells[ 0 ].Paragraphs[ 0 ].Append( "Brix:" ).Bold( );
                table.Rows[ ++c ].Cells[ 0 ].Paragraphs[ 0 ].Append( "Acid content (in citric acid):" ).Bold( );
                table.Rows[ ++c ].Cells[ 0 ].Paragraphs[ 0 ].Append( "pH:" ).Bold( );
                table.Rows[ ++c ].Cells[ 0 ].Paragraphs[ 0 ].Append( "Consistence (Bostwick, 20°C):" ).Bold( );
                table.Rows[ ++c ].Cells[ 0 ].Paragraphs[ 0 ].Append( "Added citric acid:" ).Bold( );
                table.Rows[ ++c ].Cells[ 0 ].Paragraphs[ 0 ].Append( "Added sugar:" ).Bold( );
                table.Rows[ ++c ].Cells[ 0 ].Paragraphs[ 0 ].Append( "Ascorbic acid:" ).Bold( );
                table.Rows[ ++c ].Cells[ 0 ].Paragraphs[ 0 ].Append( "Added colours:" ).Bold( );
                table.Rows[ ++c ].Cells[ 0 ].Paragraphs[ 0 ].Append( "Added flavours:" ).Bold( );
                table.Rows[ ++c ].Cells[ 0 ].Paragraphs[ 0 ].Append( "Added preservatives:" ).Bold( );
                table.Rows[ ++c ].Cells[ 0 ].Paragraphs[ 0 ].Append( "Average nutritional values in 100 g product" ).Bold( );
                table.Rows[ ++c ].Cells[ 0 ].Paragraphs[ 0 ].Append( "     Energy:" ).Bold( );
                table.Rows[ ++c ].Cells[ 0 ].Paragraphs[ 0 ].Append( "     Protein:" ).Bold( );
                table.Rows[ ++c ].Cells[ 0 ].Paragraphs[ 0 ].Append( "     Carbohydrate:" ).Bold( );
                table.Rows[ ++c ].Cells[ 0 ].Paragraphs[ 0 ].Append( "     Fat:" ).Bold( );
                table.Rows[ ++c ].Cells[ 0 ].Paragraphs[ 0 ].Append( "     Dietary fiber:" ).Bold( );
                table.Rows[ ++c ].Cells[ 0 ].Paragraphs[ 0 ].Append( "Microbiological status:" ).Bold( );
                table.Rows[ ++c ].Cells[ 0 ].Paragraphs[ 0 ].Append( "Best before:" ).Bold( );
                table.Rows[ ++c ].Cells[ 0 ].Paragraphs[ 0 ].Append( "Sieve size:" ).Bold( );
                table.Rows[ ++c ].Cells[ 0 ].Paragraphs[ 0 ].Append( "Net weight:" ).Bold( );
                table.Rows[ ++c ].Cells[ 0 ].Paragraphs[ 0 ].Append( "Storage:" ).Bold( );
                table.Rows[ ++c ].Cells[ 0 ].Paragraphs[ 0 ].Append( "Packaging:" ).Bold( );
                table.Rows[ ++c ].Cells[ 0 ].Paragraphs[ 0 ].Append( "Country of origin:" ).Bold( );
                #endregion

                #region data
                c = -1;
                table.Rows[ ++c ].Cells[ 1 ].Paragraphs[ 0 ].Append( _data.szallitolevel.Vevo ).Bold( );
                table.Rows[ ++c ].Cells[ 1 ].Paragraphs[ 0 ].Append( _data.vizsgalatilap.Megnevezes ).Bold( );
                table.Rows[ ++c ].Cells[ 1 ].Paragraphs[ 0 ].Append( _data.szallitolevel.GyartasiIdo.Substring( 0, 4 ) ).Bold( );
                table.Rows[ ++c ].Cells[ 1 ].Paragraphs[ 0 ].Append( _data.vizsgalatilap.Sarzs ).Bold( );
                table.Rows[ ++c ].Cells[ 1 ].Paragraphs[ 0 ].Append( _data.szallitolevel.Szin );
                table.Rows[ ++c ].Cells[ 1 ].Paragraphs[ 0 ].Append( _data.szallitolevel.Iz );
                table.Rows[ ++c ].Cells[ 1 ].Paragraphs[ 0 ].Append( _data.szallitolevel.Illat );
                table.Rows[ ++c ].Cells[ 1 ].Paragraphs[ 0 ].Append( MinMax( _data.vizsgalatilap.Brix ) + " %" );
                table.Rows[ ++c ].Cells[ 1 ].Paragraphs[ 0 ].Append( MinMax( _data.vizsgalatilap.Citromsav ) + " %" );
                table.Rows[ ++c ].Cells[ 1 ].Paragraphs[ 0 ].Append( MinMax( _data.vizsgalatilap.Ph ) );
                table.Rows[ ++c ].Cells[ 1 ].Paragraphs[ 0 ].Append( MinMax( _data.vizsgalatilap.Bostwick ) + " cm/30 sec" );
                if ( MinMax( _data.vizsgalatilap.CitromsavAdagolas ) == null ) { table.Rows[ ++c ].Cells[ 1 ].Paragraphs[ 0 ].Append( "no" ); } else { table.Rows[ ++c ].Cells[ 1 ].Paragraphs[ 0 ].Append( MinMax( _data.vizsgalatilap.CitromsavAdagolas ) ); }
                table.Rows[ ++c ].Cells[ 1 ].Paragraphs[ 0 ].Append( _data.fixstring.Cukor );
                table.Rows[ ++c ].Cells[ 1 ].Paragraphs[ 0 ].Append( "maximum " + _data.vizsgalatilap.Aszkorbinsav + " mg/kg" );
                table.Rows[ ++c ].Cells[ 1 ].Paragraphs[ 0 ].Append( _data.fixstring.Szinezek );
                table.Rows[ ++c ].Cells[ 1 ].Paragraphs[ 0 ].Append( _data.fixstring.Aroma );
                table.Rows[ ++c ].Cells[ 1 ].Paragraphs[ 0 ].Append( _data.fixstring.Aroma );
                table.Rows[ ++c ].Cells[ 1 ].Paragraphs[ 0 ].Append( "" );
                table.Rows[ ++c ].Cells[ 1 ].Paragraphs[ 0 ].Append( _data.tapertek.EnergiaTartalom1 + " kj / " + _data.tapertek.EnergiaTartalom2 + " kcal" );
                table.Rows[ ++c ].Cells[ 1 ].Paragraphs[ 0 ].Append( _data.tapertek.Feherje + " g" );
                table.Rows[ ++c ].Cells[ 1 ].Paragraphs[ 0 ].Append( _data.tapertek.Szenhidrat + " g" );
                table.Rows[ ++c ].Cells[ 1 ].Paragraphs[ 0 ].Append( _data.tapertek.Zsir + " g" );
                table.Rows[ ++c ].Cells[ 1 ].Paragraphs[ 0 ].Append( _data.tapertek.Elelmirost + " g" );
                table.Rows[ ++c ].Cells[ 1 ].Paragraphs[ 0 ].Append( _data.fixstring.MikroBiologia );
                table.Rows[ ++c ].Cells[ 1 ].Paragraphs[ 0 ].Append( _data.fixstring.MinosegetMegorzi );
                table.Rows[ ++c ].Cells[ 1 ].Paragraphs[ 0 ].Append( _data.vizsgalatilap.Paszirozottsag );
                table.Rows[ ++c ].Cells[ 1 ].Paragraphs[ 0 ].Append( _data.fixstring.NettoTomeg );
                table.Rows[ ++c ].Cells[ 1 ].Paragraphs[ 0 ].Append( _data.fixstring.Tarolas );
                table.Rows[ ++c ].Cells[ 1 ].Paragraphs[ 0 ].Append( "aseptic bags and " + Program.database.Törzsadat_Angol( _data.vizsgalatilap.Csomagolas ) );
                table.Rows[ ++c ].Cells[ 1 ].Paragraphs[ 0 ].Append( Program.database.Törzsadat_Angol( _data.vizsgalatilap.SzarmazasiHely ) );
                #endregion
            }
        }
Пример #33
0
        public virtual Table InsertTableBeforeSelf(Table t)
        {
            Xml.AddBeforeSelf(t.Xml);
            XElement newlyInserted = Xml.ElementsBeforeSelf().Last();

            //Dmitchern
            return new Table(Document, newlyInserted) { mainPart=mainPart}; //return new table, dont affect parameter table

            //t.Xml = newlyInserted;
            //return t;
        }
Пример #34
0
 public void InsertHead(Table table)
 {
     for (int i = 0; i < 5; i++)
     {
         table.Rows[0].Cells[i].Paragraphs[0].Append("Column Head " + i);
     }
 }
Пример #35
0
 private static void setTableStyle(Novacode.Table table)
 {
     table.Design  = TableDesign.LightGridAccent1;
     table.AutoFit = AutoFit.ColumnWidth;
 }
Пример #36
0
        public static void CreateDynamicsReport(Patient patient, IEnumerable <MedicalTest> test_list, Type test_type, PropertyInfo indicator, string file_path)
        {
            if (file_path == null)
            {
                return;
            }
            else
            {
                var norms = PatientDB.Instance.GetTestNorms(test_type)[indicator.Name];
                using (DocX document = DocX.Create(file_path))
                {
                    Novacode.Paragraph header_test = document.InsertParagraph(
                        test_type.GetCustomAttribute <DisplayNameAttribute>().DisplayName,
                        false,
                        new Formatting()
                    {
                        FontFamily = new System.Drawing.FontFamily("Times New Roman"),
                        Size       = 18D
                    }
                        );
                    header_test.Alignment = Alignment.center;
                    header_test.Bold();
                    Novacode.Paragraph header_indicator = document.InsertParagraph(
                        indicator.GetCustomAttribute <TestInfo>().DisplayName,
                        false,
                        new Formatting()
                    {
                        FontFamily = new System.Drawing.FontFamily("Times New Roman"),
                        Size       = 16D
                    }
                        );
                    header_indicator.Alignment = Alignment.center;
                    header_indicator.Bold();
                    document.InsertParagraph(" ");
                    Novacode.Table patient_info = document.AddTable(5, 2);
                    patient_info.Rows[0].Cells[0].Paragraphs.First().Append("ФИО пациента").Bold();
                    patient_info.Rows[0].Cells[1].Paragraphs.First().Append(patient.LastName + " " + patient.FirstName + " " + patient.Patronym);
                    patient_info.Rows[1].Cells[0].Paragraphs.First().Append("Пол").Bold();
                    patient_info.Rows[1].Cells[1].Paragraphs.First().Append(patient.Sex == Sex.мужской ? "мужской" : "женский");
                    patient_info.Rows[2].Cells[0].Paragraphs.First().Append("Дата рождения").Bold();
                    patient_info.Rows[2].Cells[1].Paragraphs.First().Append(patient.Birthdate.ToShortDateString());
                    patient_info.Rows[3].Cells[0].Paragraphs.First().Append("Адрес проживания").Bold();
                    patient_info.Rows[3].Cells[1].Paragraphs.First().Append(
                        patient.PostIndex + ", " + patient.Country + ", " + patient.Region +
                        ", " + patient.City + ", " + patient.Address
                        );
                    patient_info.Rows[4].Cells[0].Paragraphs.First().Append("Номер карты").Bold();
                    patient_info.Rows[4].Cells[1].Paragraphs.First().Append(patient.CardNumber.ToString());
                    patient_info.Alignment = Alignment.left;
                    patient_info.AutoFit   = AutoFit.Window;
                    Novacode.Table dynamics = document.AddTable(test_list.Count() + 1, 2);
                    dynamics.Rows[0].Cells[0].Paragraphs.First().Append("Дата сдачи анализов").Bold();
                    dynamics.Rows[0].Cells[1].Paragraphs.First().Append("Значение показателя (" + indicator.GetCustomAttribute <TestInfo>().Unity.GetDescription() + ")").Bold();
                    int k = 1;
                    foreach (var test_ in test_list.OrderBy(x => x.Date))
                    {
                        double value_ = (double)indicator.GetValue(test_);
                        dynamics.Rows[k].Cells[0].Paragraphs.First().Append(test_.Date.ToShortDateString());
                        if (value_ >= norms.Min - norms.MinError && value_ <= norms.Max + norms.MaxError)
                        {
                            dynamics.Rows[k].Cells[1].Paragraphs.First().Append(value_.ToString()).Highlight(Highlight.green);
                        }
                        else
                        {
                            dynamics.Rows[k].Cells[1].Paragraphs.First().Append(value_.ToString()).Highlight(Highlight.red);
                        }
                        k++;
                    }
                    dynamics.Alignment = Alignment.left;
                    dynamics.AutoFit   = AutoFit.Window;
                    document.InsertTable(patient_info);
                    document.InsertParagraph(" ");
                    document.InsertTable(dynamics);

                    /*
                     * bitmap_encoder = new PngBitmapEncoder();
                     * using (MemoryStream pic_stream = new MemoryStream())
                     * {
                     *  bitmap_encoder.Frames.Add(BitmapFrame.Create(rtb));
                     *  bitmap_encoder.Save(pic_stream);
                     *  pic_stream.Seek(0, SeekOrigin.Begin);
                     *  document.InsertParagraph(" ");
                     *  Novacode.Picture graph = document.AddImage(pic_stream).CreatePicture();
                     *  graph.SetPictureShape(Novacode.RectangleShapes.rect);
                     *  Novacode.Paragraph graph_paragraph = document.InsertParagraph();
                     *  graph_paragraph.InsertPicture(graph);
                     * }
                     */
                    document.Save();
                }
            }
        }
Пример #37
0
 public static IEnumerable<TemplMatchTable> Find(TemplRegex rxp, Table t, int rowIdx, int cellIdx,
     uint maxPerCell = TemplConst.MaxMatchesPerScope)
 {
     return Find<TemplMatchTable>(rxp, t.Rows[rowIdx].Cells[cellIdx].Paragraphs).Select(m =>
     {
         m.Table = t;
         m.RowIndex = rowIdx;
         m.CellIndex = cellIdx;
         return m;
     }).Take((int)maxPerCell);
 }
Пример #38
0
 /// <summary>
 /// Insert a Table into this document. The Table's source can be a completely different document.
 /// </summary>
 /// <param name="t">The Table to insert.</param>
 /// <param name="index">The index to insert this Table at.</param>
 /// <returns>The Table now associated with this document.</returns>
 /// <example>
 /// Extract a Table from document a and insert it into document b, at index 10.
 /// <code>
 /// // Place holder for a Table.
 /// Table t;
 ///
 /// // Load document a.
 /// using (DocX documentA = DocX.Load(@"C:\Example\a.docx"))
 /// {
 ///     // Get the first Table from this document.
 ///     t = documentA.Tables[0];
 /// }
 ///
 /// // Load document b.
 /// using (DocX documentB = DocX.Load(@"C:\Example\b.docx"))
 /// {
 ///     /* 
 ///      * Insert the Table that was extracted from document a, into document b. 
 ///      * This creates a new Table that is now associated with document b.
 ///      */
 ///     Table newTable = documentB.InsertTable(10, t);
 ///
 ///     // Save all changes made to document b.
 ///     documentB.Save();
 /// }// Release this document from memory.
 /// </code>
 /// </example>
 public new Table InsertTable(int index, Table t)
 {
     Table t2 = base.InsertTable(index, t);
     t2.mainPart = mainPart;
     return t2;
 }
Пример #39
0
        public virtual Table InsertTableAfterSelf(Table t)
        {
            Xml.AddAfterSelf(t.Xml);
            XElement newlyInserted = Xml.ElementsAfterSelf().First();
            //Dmitchern
            return new Table(Document, newlyInserted); //return new table, dont affect parameter table

            //t.Xml = newlyInserted;
            //return t;
        }
Пример #40
0
 /// <summary>
 /// 合并单元格
 /// </summary>
 /// <param name="t"></param>
 /// <param name="isRows">true则合并同行不同列,false则合并同列不同行</param>
 /// <param name="index">合并行或列的索引</param>
 /// <param name="startIndex">开始的索引</param>
 /// <param name="endIndex">结束的索引</param>
 public static void mergeCells(Table t, bool isRows, int index, int startIndex, int endIndex)
 {
     if (isRows)
     {
         t.Rows[index].MergeCells(startIndex, endIndex);
     }
     else
     {
         t.MergeCellsInColumn(index, startIndex, endIndex);
     }
 }
Пример #41
0
 //设置单元格值
 public static void setCellvalue(Table t, int rowindex, int colindex, string value)
 {
     t.Rows[rowindex].Cells[colindex].Paragraphs.First().InsertText(value, false);
 }
Пример #42
0
 internal Row(Table table, DocX document, XElement xml)
     : base(document, xml)
 {
     this.table = table;
     this.mainPart = table.mainPart;
 }
Пример #43
0
 //设置单元格样式,感觉通过获取表格来直接设置就好,不然对属性和值不能确定
 public static void setTablestyle(Table t, string style, string value)
 {
     //t.Rows[rowindex].Cells[colindex].FillColor = Color.AliceBlue;
     //t.Rows[rowindex].Cells[colindex].Paragraphs.First().Append(value).Color(Color.Black);
 }
Пример #44
0
 /// <summary>
 /// Insert a new Table before this Table, this Table can be from this document or another document.
 /// </summary>
 /// <param name="t">The Table t to be inserted</param>
 /// <returns>A new Table inserted before this Table.</returns>
 /// <example>
 /// Insert a new Table before this Table.
 /// <code>
 /// // Place holder for a Table.
 /// Table t;
 ///
 /// // Load document a.
 /// using (DocX documentA = DocX.Load(@"a.docx"))
 /// {
 ///     // Get the first Table from this document.
 ///     t = documentA.Tables[0];
 /// }
 ///
 /// // Load document b.
 /// using (DocX documentB = DocX.Load(@"b.docx"))
 /// {
 ///     // Get the first Table in document b.
 ///     Table t2 = documentB.Tables[0];
 ///
 ///     // Insert the Table from document a before this Table.
 ///     Table newTable = t2.InsertTableBeforeSelf(t);
 ///
 ///     // Save all changes made to document b.
 ///     documentB.Save();
 /// }// Release this document from memory.
 /// </code>
 /// </example>
 public override Table InsertTableBeforeSelf(Table t)
 {
     return base.InsertTableBeforeSelf(t);
 }
Пример #45
0
        private void AdatTablazatFormazas( Table table ) {
            Border b = new Border(Novacode.BorderStyle.Tcbs_none, BorderSize.seven, 0, Color.Blue);
            Border c = new Border(Novacode.BorderStyle.Tcbs_single, BorderSize.seven, 0, Color.Black);

            table.SetBorder( TableBorderType.InsideH, b );
            table.SetBorder( TableBorderType.InsideV, b );
            table.SetBorder( TableBorderType.Bottom, b );
            table.SetBorder( TableBorderType.Top, b );
            table.SetBorder( TableBorderType.Left, b );
            table.SetBorder( TableBorderType.Right, b );

            for( int i = 0; i < 4; i++ ) {
                table.Rows[0].Cells[i].SetBorder( TableCellBorderType.Bottom, c );
            }

            table.AutoFit = AutoFit.ColumnWidth;
            foreach( Row row in table.Rows ) {
                row.Cells[0].Width = 100;
                row.Cells[1].Width = 250;
                row.Cells[2].Width = 250;
                row.Cells[3].Width = 100;
            }

            foreach( Row row in table.Rows ) {
                row.Height = 20;
            }
        }
Пример #46
0
        public static DocX CreateDocA(DocX template, ECEViewModel model, string source, bool cprvalue)
        {
            bool   addcor  = false;
            string Fadcorr = "";
            bool   special = false;
            string Fsnum   = "[NUMBER]";
            string sym     = getSym(model);

            if (!String.IsNullOrEmpty(model.Prep))
            {
                sym = sym.Replace("#", model.Prep.ToString());
            }
            if (cprvalue == true)
            {
                sym = sym + "/CRP." + model.cprnum.ToString();
            }
            if (!String.IsNullOrEmpty(model.Add) && model.cAdd == true && model.cCor == false)
            {
                sym     = sym + "/Add." + model.Add.ToString();
                Fadcorr = "Addendum";
                addcor  = true;
            }
            if (!String.IsNullOrEmpty(model.Cor) && model.cCor == true && model.cAdd == false)
            {
                sym     = sym + "/Corr." + model.Cor.ToString();
                Fadcorr = "Corrigendum";
                addcor  = true;
            }
            if (!String.IsNullOrEmpty(model.Cor) && !String.IsNullOrEmpty(model.Add) && model.cCor == true && model.cAdd == true)
            {
                sym     = sym + "/Add." + model.Add.ToString() + "/Corr." + model.Cor.ToString();
                Fadcorr = "Addendum Corrigendum";
                addcor  = true;
            }
            if (String.IsNullOrEmpty(model.Cor) && String.IsNullOrEmpty(model.Add))
            {
                addcor = false;
            }
            if (String.IsNullOrEmpty(model.CaseYear))
            {
                sym = sym.Replace("&", DateTime.Now.Year.ToString());
            }
            if (!String.IsNullOrEmpty(model.CaseYear))
            {
                sym = sym.Replace("&", model.CaseYear.ToString());
            }
            model.tsym = sym;
            string[] SymStr = sym.Split('/');
            string[] sym1   = SymStr.Skip(1).ToArray();
            string   Fsym   = String.Join("/", sym1);

            if (Fsym.Contains("/S/"))
            {
                special = true;
                Fsnum   = "special";
            }
            //Create Date for Header
            string Fdate = model.date.ToString();

            string[] d = Fdate.Split(' ');
            Fdate = d[0];
            Fdate = formatdate(Fdate, model);


            //Create Distribution for Header
            string Fdist = getDist(model);

            //Create Virsions for Header
            string Fvirs = "";

            //if (model.version1 != null)
            //{
            //    int deleteStart = 0;
            //    int deleteEnd = 0;

            //    //Get the array of the paragraphs containing the start and end catches
            //    for (int i = 0; i < template.Paragraphs.Count; i++)
            //    {
            //        if (template.Paragraphs[i].Text.Contains("Original"))
            //            deleteStart = i;
            //        if (template.Paragraphs[i].Text.Contains("olang"))
            //            deleteEnd = i;
            //    }

            //    if (deleteStart > 0 && deleteEnd > 0)
            //    {
            //        //delete from the paraIndex as the arrays will shift when a paragraph is deleted
            //        int paraIndex = deleteStart;
            //        for (int i = deleteStart; i <= deleteEnd; i++)
            //        {
            //            template.RemoveParagraphAt(paraIndex);
            //        }
            //    }
            //}

            //Fvirs = getVerisons(model);

            string Folang = "";

            Folang = Olanguage(model.lang_ID);

            string Fatitle = "[Title]";

            if (!String.IsNullOrEmpty(model.AgendaItem))
            {
                Fatitle = model.AgendaItem.ToString();
            }
            string Fsdate = "[Start-End Dates ]";

            if (model.Sdate != null & model.Edate != null)
            {
                string   sdate = model.Sdate.ToString();
                string[] sd    = sdate.Split(' ');
                sdate = sd[0];
                sdate = formatdate(sdate, model);

                string   edate = model.Edate.ToString();
                string[] ed    = edate.Split(' ');
                edate = ed[0];
                edate = formatdate(edate, model);


                Fsdate = SessionDate(sdate, edate, model);
            }
            string Fldate = "[Start Date]";

            if (model.Sdate != null & model.Edate != null)
            {
                string   ldate = model.Sdate.ToString();
                string[] ld    = ldate.Split(' ');
                ldate = ld[0];
                string dldate = System.Threading.Thread.CurrentThread.CurrentUICulture.DateTimeFormat.GetDayName(DateTime.Parse(ldate).DayOfWeek);
                ldate = formatdate(ldate, model);
                //Regex rx = new Regex(@"^\d+\p{Zs}", RegexOptions.Compiled);
                //ldate = rx.Replace(ldate, dldate+" ");
                ldate  = dldate + " " + ldate;
                Fldate = ldate;
            }

            string Fanum = "[NUMBER]";

            if (!String.IsNullOrEmpty(model.AgendaNum))
            {
                Fanum = model.AgendaNum.ToString();
            }

            if (special == false)
            {
                if (!String.IsNullOrEmpty(model.SNum))
                {
                    Fsnum = Sessionnum(model);
                }
            }



            if (model.qrcode == true)
            {
                string lang = language(model.lang_ID);
                lang = lang.Substring(0, 1);


                string url = "http://undocs.org/m2/QRCode.ashx?DS=" + Fsym + "&Size=2&Lang=" + lang;
                using (var client = new WebClient())
                {
                    //var content = client.DownloadData("https://api.qrserver.com/v1/create-qr-code/?size=66x66&data=http://undocs.org/fr/A/HRC/70");
                    //var content = client.DownloadData("http://undocs.org/m2/QRCode.ashx?DS=A/HRC/70&Size=2&Lang=F");
                    var content = client.DownloadData(url);

                    using (var str = new MemoryStream(content))
                    {
                        if (lang == "A")
                        {
                            Image     image = template.AddImage(str);
                            NVPicture p     = image.CreatePicture();
                            NVFooter  f     = template.Footers.first;
                            NVTable   t     = f.Tables[0];
                            //t.Rows[0].Cells[1].Paragraphs.First().AppendPicture(pR);
                            t.Rows[0].Cells[0].Paragraphs.First().AppendPicture(p);
                        }
                        else
                        {
                            NVImage   image = template.AddImage(str);
                            NVPicture p     = image.CreatePicture();
                            NVFooter  f     = template.Footers.first;
                            NVTable   t     = f.Tables[0];
                            //t.Rows[0].Cells[1].Paragraphs.First().AppendPicture(pR);
                            t.Rows[0].Cells[1].Paragraphs.First().AppendPicture(p);
                        }
                    }
                }
            }
            string Fcategory = "";

            Fcategory = getCat(model.Cat);
            string FSubcategory = "";

            if (model.SCat != "Not Applicable" || model.SCat != "Special Session")
            {
                FSubcategory = model.SCat.ToString();
            }
            if (model.SCat == "Not Applicable" || model.SCat == "Special Session")
            {
                int deleteStart = 0;
                int deleteEnd   = 0;

                //Get the array of the paragraphs containing the start and end catches
                for (int i = 0; i < template.Paragraphs.Count; i++)
                {
                    if (template.Paragraphs[i].Text.Contains("subcategory"))
                    {
                        deleteStart = i;
                    }
                    if (template.Paragraphs[i].Text.Contains("subcategory"))
                    {
                        deleteEnd = i;
                    }
                }

                if (deleteStart > 0 && deleteEnd > 0)
                {
                    //delete from the paraIndex as the arrays will shift when a paragraph is deleted
                    int paraIndex = deleteStart;
                    for (int i = deleteStart; i <= deleteEnd; i++)
                    {
                        template.RemoveParagraphAt(paraIndex);
                    }
                }
            }
            if (addcor == false)
            {
                int deleteStart = 0;
                int deleteEnd   = 0;

                //Get the array of the paragraphs containing the start and end catches
                for (int i = 0; i < template.Paragraphs.Count; i++)
                {
                    if (template.Paragraphs[i].Text.Contains("adcorr"))
                    {
                        deleteStart = i;
                    }
                    if (template.Paragraphs[i].Text.Contains("adcorr"))
                    {
                        deleteEnd = i;
                    }
                }

                if (deleteStart > 0 && deleteEnd > 0)
                {
                    //delete from the paraIndex as the arrays will shift when a paragraph is deleted
                    int paraIndex = deleteStart;
                    for (int i = deleteStart; i <= deleteEnd; i++)
                    {
                        template.RemoveParagraphAt(paraIndex);
                    }
                }
            }
            string Fsplace = "[Session City]";

            if (!String.IsNullOrEmpty(model.splace))
            {
                Fsplace = model.splace.ToString();
            }
            string Floca = "[Session Location]";

            if (!String.IsNullOrEmpty(model.loca))
            {
                Floca = model.loca.ToString() + ", " + Fsplace;
            }

            DateTime x = DateTime.Now;

            string[] info1 = info(model);

            template.AddCustomProperty(new CustomProperty("sym1", Fsym));
            template.AddCustomProperty(new CustomProperty("symh", sym));
            template.AddCustomProperty(new CustomProperty("dist", Fdist));
            template.AddCustomProperty(new CustomProperty("date", Fdate));
            template.AddCustomProperty(new CustomProperty("sdate", Fsdate));
            template.AddCustomProperty(new CustomProperty("virs", Fvirs));
            template.AddCustomProperty(new CustomProperty("snum", Fsnum));
            template.AddCustomProperty(new CustomProperty("anum", Fanum));
            template.AddCustomProperty(new CustomProperty("adcorr", Fadcorr));
            template.AddCustomProperty(new CustomProperty("gdoc", ""));
            template.AddCustomProperty(new CustomProperty("gdocf", ""));
            template.AddCustomProperty(new CustomProperty("tlang", ""));
            template.AddCustomProperty(new CustomProperty("atitle", Fatitle));
            template.AddCustomProperty(new CustomProperty("ldate", Fldate));
            template.AddCustomProperty(new CustomProperty("loca", Floca));
            template.AddCustomProperty(new CustomProperty("categ", Fcategory));
            template.AddCustomProperty(new CustomProperty("subcategory", FSubcategory));
            template.AddCustomProperty(new CustomProperty("splace", Fsplace));
            template.AddCustomProperty(new CustomProperty("olang", Folang));
            template.AddCustomProperty(new CustomProperty("Date-Generated", x));
            template.AddCustomProperty(new CustomProperty("Org", "ECE"));
            template.AddCustomProperty(new CustomProperty("Entity", info1[0]));
            template.AddCustomProperty(new CustomProperty("doctype", info1[1]));
            template.AddCustomProperty(new CustomProperty("category", info1[2]));
            template.AddCustomProperty(new CustomProperty("bar", ""));

            for (int i = 0; i < template.Paragraphs.Count; i++)
            {
                if (template.Paragraphs[i].Text.Contains(Fsnum))
                {
                    string Fsnum1 = char.ToUpper(Fsnum[0]) + Fsnum.Substring(1);
                    template.Paragraphs[i].ReplaceText(Fsnum, Fsnum1);
                    break;
                }
            }
            if (addcor == true && cprvalue == false)
            {
                int deleteStart = 0;
                int deleteEnd   = 0;

                //Get the array of the paragraphs containing the start and end catches
                for (int i = 0; i < template.Paragraphs.Count; i++)
                {
                    if (template.Paragraphs[i].Text.Contains("*"))
                    {
                        deleteStart = i;
                    }

                    if (template.Paragraphs[i].Text.Contains(Fadcorr))
                    {
                        deleteEnd = i;
                    }
                }

                if (deleteStart > 0 && deleteEnd > 0)
                {
                    //delete from the paraIndex as the arrays will shift when a paragraph is deleted
                    int paraIndex = deleteEnd - deleteStart;
                    paraIndex = deleteStart + paraIndex - 1;

                    template.RemoveParagraphAt(paraIndex);
                }
                //List <string> replace = template.FindUniqueByPattern("*", RegexOptions.None);
                //foreach (string s in replace)
                //{
                //    if (!s.Equals("")) template.ReplaceText((s, "");
                //}

                template.ReplaceText("*", "");

                List <string> repl = template.FindUniqueByPattern(",\\s", RegexOptions.None);
                foreach (string rep in repl)
                {
                    if (!String.IsNullOrEmpty(rep))
                    {
                        template.ReplaceText(rep, "");
                    }
                }



                //bool flag = false;
                //List<List<string>> list1 = new List<List<string>>();
                //List<string> list2 = new List<string>();
                //foreach (Novacode.Paragraph item in template.Paragraphs)
                //{
                //    //use this if you need whole text of a paragraph
                //    string paraText = item.Text;
                //    var result = paraText.Split(' ');
                //    int count = 0;
                //    list2 = new List<string>();
                //    //use this if you need word by word
                //    foreach (var data in result)
                //    {
                //        string word = data.ToString();

                //        if (word.Contains(Fsnum)) flag = true;
                //        if (word.Contains("session"))
                //        {
                //            flag = false;
                //            // list2.Add(word);
                //        }
                //        if (flag)
                //            list2.Add(word);
                //        count++;
                //    }
                //    //    list2.RemoveAt(0);

                //    list1.Add(list2);

                //}
                ////   list1[0].Replace(list1[0], "*");
                //for (int i = 0; i < list1.Count(); i++)
                //{

                //    string temp = "";
                //    for (int y = 0; y < list1[i].Count(); y++)
                //    {
                //        if (y == 0)
                //        {
                //            temp = list1[i][y];
                //            continue;
                //        }
                //        temp += " " + list1[i][y];
                //        //   temp = temp.Remove(temp.IndexOf(',')-1, temp.Length);
                //    }
                //    int ind = temp.IndexOf("*");

                //    // temp = temp.Substring(ind, temp.Length - ind);
                //    if (!temp.Equals("")) template.ReplaceText("Done", "");
                //}
            }
            //using (WordprocessingDocument

            // document = WordprocessingDocument.Open(source, true))

            //{
            //    var bookMarks = FindBookmarks(document.MainDocumentPart.Document);
            //}
            // Return the template now that it has been modified to hold all of our custom data.
            return(template);
        }
Пример #47
0
        /// <summary>
        /// 获取节点中表的信息
        /// </summary>
        /// <param name="table">table</param>
        private TableInfo GetTable(Table table)
        {
            try
            {
                TableInfo mTable = new TableInfo();
                List<ColumnInfo> list = new List<ColumnInfo>();
                List<PkKeyInfo> listPkKeyInfo = new List<PkKeyInfo>();
                mTable.ListColumnInfo = list;
                mTable.ListPkKeyInfo = listPkKeyInfo;
                //表的ID
                mTable.TableObjectID = Guid.NewGuid().ToString();
                //表的中文名称
                mTable.Name = Common.GetTableCName(table.Rows[0].Cells[1].Paragraphs[0].Text.Trim());
                //表的英文名称
                mTable.Code = table.Rows[1].Cells[1].Paragraphs[0].Text.Trim();
                //2014-07-28 添加错误详细信息提示,以便准确知道错误地方
                Common.JudgeTableInfo(mTable.Code, mTable.Name);
                //表的描述
                mTable.Comment = mTable.Name;

                //标题列
                var row = table.Rows[3];
                //缓存列索引和名称
                Dictionary<int, string> dic = new Dictionary<int, string>();
                int i = 0;
                foreach (var cell in row.Cells)
                {
                    dic.Add(i, cell.Paragraphs[0].Text.Trim());
                    i++;
                }

                for (i = 4; i < table.Rows.Count; i++)
                {
                    row = table.Rows[i];
                    InitColumns(row, dic, mTable);
                }

                if (string.IsNullOrEmpty(mTable.Comment))
                {
                    mTable.Comment = mTable.Name;
                }
                if (mTable.ListPkKeyInfo != null && mTable.ListPkKeyInfo.Count > 0)
                {
                    foreach (PkKeyInfo pkInfo in mTable.ListPkKeyInfo)
                    {
                        mTable.PkKeyNameList = String.Format("{0}{1},", mTable.PkKeyNameList, pkInfo.Name);
                    }
                }
                if (!string.IsNullOrEmpty(mTable.PkKeyNameList))
                {
                    mTable.PkKeyNameList = mTable.PkKeyNameList.Substring(0, mTable.PkKeyNameList.Length - 1);
                }
                return mTable;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #48
0
        public Table InsertTable(int index, Table t)
        {
            Paragraph p = HelperFunctions.GetFirstParagraphEffectedByInsert(Document, index);

            XElement[] split = HelperFunctions.SplitParagraph(p, index - p.startIndex);
            XElement newXElement = new XElement(t.Xml);
            p.Xml.ReplaceWith
            (
                split[0],
                newXElement,
                split[1]
            );

            Table newTable = new Table(Document, newXElement)
            {
                mainPart = mainPart,
                Design = t.Design
            };

            return newTable;
        }
Пример #49
0
 private void ExportWord()
 {
     if (Tables != null)
     {
         var columns = Columns;
         using (Docx.DocX doc = Docx.DocX.Create(FileName))
         {
             //表格的边框样式
             Docx.Border border = new Docx.Border();
             border.Tcbs = Docx.BorderStyle.Tcbs_single;
             int n = 0;
             foreach (TableEntity tableEntity in Tables)
             {
                 string tableId = tableEntity.ID.ToString();
                 //插入表名
                 Docx.Paragraph title = doc.InsertParagraph();
                 title.Append(tableEntity.TableName + "(" + tableEntity.Attr + ")");
                 title.Alignment = Docx.Alignment.center;
                 title.FontSize(15);
                 title.Bold();
                 title.SetLineSpacing(Docx.LineSpacingType.After, 1);
                 title.SetLineSpacing(Docx.LineSpacingType.Before, 1);
                 DataTable fields   = service.GetColumnDataTable(tableId);
                 int       rowCount = (fields == null ? 0 : fields.Rows.Count) + 1;
                 //计算表格多少行,多少列
                 Docx.Table table = doc.InsertTable(rowCount, columns.Count);
                 //先生成列头
                 Docx.Row colRow = table.Rows[0];
                 int      k      = 0;
                 foreach (string colKey in columns.Keys)
                 {
                     Docx.Cell colCell = colRow.Cells[k];
                     colCell.Paragraphs[0].Append(columns[colKey]).Alignment = Docx.Alignment.center;
                     colCell.SetBorder(Docx.TableCellBorderType.Top, border);
                     colCell.SetBorder(Docx.TableCellBorderType.Bottom, border);
                     colCell.SetBorder(Docx.TableCellBorderType.Left, border);
                     colCell.SetBorder(Docx.TableCellBorderType.Right, border);
                     k++;
                 }
                 for (int i = 0; i < fields.Rows.Count; i++)
                 {
                     //一个属性为一行
                     Docx.Row row = table.Rows[i + 1];
                     //循环每列
                     int j = 0;
                     foreach (string key in columns.Keys)
                     {
                         Docx.Cell cell = row.Cells[j];
                         string    text = fields.Rows[i][key].ToString();
                         if (key == requiredKey)
                         {
                             text = text.ToLower() == "true" ? "是" : "";
                         }
                         cell.Paragraphs[0].Append(text).Alignment = Docx.Alignment.center;
                         cell.Paragraphs[0].FontSize(10);
                         cell.SetBorder(Docx.TableCellBorderType.Top, border);
                         cell.SetBorder(Docx.TableCellBorderType.Bottom, border);
                         cell.SetBorder(Docx.TableCellBorderType.Left, border);
                         cell.SetBorder(Docx.TableCellBorderType.Right, border);
                         j++;
                     }
                 }
                 n++;
                 if (OnProgress != null)
                 {
                     OnProgress(this, new ProgressEventArgs()
                     {
                         Max = Tables.Count, Value = n
                     });
                 }
             }
             doc.Save();
         }
     }
 }
Пример #50
0
        private void btnAsinar_Click(object sender, RoutedEventArgs e)
        {
            List <int> Seleccionados = new List <int>();
            bool       revCM = false, revDev = false, revPPQA = false;

            foreach (Contenido item in lstCM.Items)
            {
                if (item.isCheked)
                {
                    Seleccionados.Add(item.id);
                    revCM = true;
                }
            }
            foreach (Contenido item in lstDev.Items)
            {
                if (item.isCheked)
                {
                    Seleccionados.Add(item.id);
                    revDev = true;
                }
            }
            foreach (Contenido item in lstPPQA.Items)
            {
                if (item.isCheked)
                {
                    Seleccionados.Add(item.id);
                    revPPQA = true;
                }
            }
            if (!revCM)
            {
                MessageBox.Show("Debes seleccionar un CM");
                return;
            }
            if (!revDev)
            {
                MessageBox.Show("Debes seleccionar un Desarrollador");
                return;
            }
            if (!revPPQA)
            {
                MessageBox.Show("Debes seleccionar un PPQA");
                return;
            }
            Service1Client cliente  = new Service1Client();
            int            idTicket = int.Parse(lblTicket.Content.ToString());
            bool           correcto = cliente.AsignaPersonal(idTicket, Seleccionados.ToArray(), Seguridad.Seguridad.saltkey);

            if (!correcto)
            {
                MessageBox.Show("Error al guardar información");
                return;
            }
            UsuarioFirmado UsuFirmado = (UsuarioFirmado)Application.Current.Resources["UserFirmado"];
            SolicitudPPQA  Solicitud  = cliente.GetSolicitudPPQA(idTicket, Seguridad.Seguridad.saltkey);

            UsuariosInvolucrados[] Usuarios = cliente.GetInvolucrados(idTicket, Seguridad.Seguridad.saltkey);
            string NombreDocumento          = "KSDP_PPQA_F04_AsignaciónRecursos.docx";
            string Ruta = System.AppDomain.CurrentDomain.BaseDirectory;

            Ruta += "Documentos/" + NombreDocumento;
            CreaEstructura CCrea        = new CreaEstructura();
            UsuarioSVN     usuSVNRuta   = cliente.GetRuta(idTicket, UsuFirmado.IdEmpleado, Seguridad.Seguridad.saltkey);
            UsuarioSVN     usuSVNContra = cliente.ObtenerUsuarioSVN(UsuFirmado.IdEmpleado, Seguridad.Seguridad.saltkey);
            string         RutaSVN      = CCrea.Inicio(usuSVNRuta.RutaLocal);

            using (var documento = DocX.Load(Ruta))
            {
                documento.ReplaceText("@cliente", Solicitud.cliente);
                documento.ReplaceText("@app", Solicitud.app);
                documento.ReplaceText("@identificador", Solicitud.identificador);
                documento.ReplaceText("@fecha", DateTime.Now.ToShortDateString());
                documento.ReplaceText("@nombrepro", Solicitud.nombrepro);
                documento.ReplaceText("@descpro", Solicitud.descripcion);
                documento.ReplaceText("@lider", Solicitud.Lider);
                Novacode.Table myTable = documento.Tables[0];
                foreach (UsuariosInvolucrados usu in Usuarios)
                {
                    Row myRow = myTable.InsertRow();
                    myRow.Cells[0].Paragraphs.First().Append(usu.Nombre);
                    myRow.Cells[1].Paragraphs.First().Append(usu.Puesto);
                    myRow.Cells[2].Paragraphs.First().Append(usu.Iniciales);
                    myRow.Cells[3].Paragraphs.First().Append(usu.Funciones);
                    myTable.Rows.Add(myRow);
                }
                documento.SaveAs(RutaSVN + "/" + NombreDocumento);
            }
            MessageBox.Show("Se agrego correctamente el documento");
        }
Пример #51
0
 internal void NewTbl()
 {
     tbl = doc.AddTable(1, 1);
     tbly = 0;
 }
Пример #52
0
 public static IEnumerable<TemplMatchTable> Find(TemplRegex rxp, Table t, int rowIdx,
     uint maxPerRow = TemplConst.MaxMatchesPerScope,
     uint maxPerCell = TemplConst.MaxMatchesPerScope)
 {
     return Enumerable.Range(0,t.Rows[rowIdx].Cells.Count).SelectMany(cellIdx => Find(rxp, t, rowIdx, cellIdx, maxPerCell)).Take((int)maxPerRow);
 }
Пример #53
0
        public static void createTaskDocument(List <string> textForQRcode, string nameWorker, List <string> typeOfWork, List <string> infoAboutAuto, List <string> infoAboutDetails, List <DateTime> dateTimeStart, List <DateTime> dateTimeFinish)
        {
            // Create a document in memory:
            var doc = DocX.Create("Task" + ".docx");

            doc.PageLayout.Orientation = Novacode.Orientation.Landscape;
            for (int i = 0; i < textForQRcode.Count(); i++)
            {
                var text = "Завдання \"" + typeOfWork[i] + "\"\n\n";

                var format = new Formatting();
                format.Size       = 24D;
                format.FontFamily = new System.Drawing.FontFamily("Times New Roman");

                var format1 = new Formatting();
                format1.Size       = 20D;
                format1.Bold       = true;
                format1.FontFamily = new System.Drawing.FontFamily("Times New Roman");

                Paragraph title = doc.InsertParagraph(text, false, format);
                title.Alignment = Alignment.center;

                Novacode.Table table = doc.AddTable(1, 3);

                table.Design    = Novacode.TableDesign.TableNormal;
                table.Alignment = Alignment.left;

                using (var ms = new MemoryStream())
                {
                    System.Drawing.Image qrCode = generateQR(textForQRcode[i]);

                    qrCode.Save(ms, System.Drawing.Imaging.ImageFormat.Bmp);  // Save your picture in a memory stream.
                    ms.Seek(0, SeekOrigin.Begin);

                    Novacode.Image img = doc.AddImage(ms); // Create image.

                    Picture pic1 = img.CreatePicture();    // Create picture.

                    table.Rows[0].Cells[0].Paragraphs.First().InsertPicture(pic1, 0);
                }

                format.Size = 18D;
                table.SetWidths(new float[] { 300, 200, 750 });
                table.Rows[0].Cells[2].Paragraphs.First().InsertText("Автомобіль - ", false, format);
                table.Rows[0].Cells[2].Paragraphs.First().InsertText(infoAboutAuto[i], false, format1);
                table.Rows[0].Cells[2].InsertParagraph("Деталі : \n", false, format).InsertText(infoAboutDetails[i], false, format1);
                table.Rows[0].Cells[2].InsertParagraph("Виконавець(по плану) - ", false, format).InsertText(nameWorker, false, format1);
                table.Rows[0].Cells[2].InsertParagraph("Початок роботи - ", false, format).InsertText(dateTimeStart[i].ToString(), false, format1);
                table.Rows[0].Cells[2].InsertParagraph("Кінець роботи - ", false, format).InsertText(dateTimeFinish[i].ToString(), false, format1);


                doc.InsertTable(table);
                if (textForQRcode.Count() - i > 1)
                {
                    doc.InsertSectionPageBreak();
                }

                doc.PageLayout.Orientation = Novacode.Orientation.Landscape;
            }
            doc.Save();
            ViewModels.ClassForAudio.playScan();
        }