Example #1
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();
            }
        }
Example #2
0
        /// <summary>
        /// Initialize Word Report --> Support Method
        /// </summary>
        public static void InsertSummaryResults()
        {
            try
            {
                Table table = resultSummarydocument.AddTable(1, 4);
                // Specify some properties for this Table.
                table.Alignment = Alignment.left;
                table.AutoFit   = AutoFit.Contents;
                table.Design    = TableDesign.TableGrid;
                table.SetColumnWidth(0, 667.87);
                table.SetColumnWidth(1, 5347.87);
                table.SetColumnWidth(2, 1255.87);
                table.SetColumnWidth(3, 1825.82);

                table.Rows[0].Cells[0].Paragraphs.First().Append(smrw.ToString() + ".");
                smrw += 1;
                table.Rows[0].Cells[1].Paragraphs.First().Append(BaseUtilities.scenarioName);
                switch (BaseUtilities.scenarioStatus.ToLower())
                {
                case "pass":

                    table.Rows[0].Cells[2].Paragraphs.First().Append("Pass").Color(System.Drawing.Color.FromArgb(52, 168, 83));
                    break;

                case "fail":

                    table.Rows[0].Cells[2].Paragraphs.First().Append("Fail").Color(System.Drawing.Color.FromArgb(234, 67, 53));
                    break;

                case "skip":

                    table.Rows[0].Cells[2].Paragraphs.First().Append("Skip").Color(System.Drawing.Color.FromArgb(234, 67, 53));
                    break;
                }


                Hyperlink link = resultSummarydocument.AddHyperlink("Click here", new Uri(reportpath));
                table.Rows[0].Cells[3].Paragraphs.First().AppendHyperlink(link).Color(System.Drawing.Color.FromArgb(1, 91, 168));

                resultSummarydocument.InsertTable(table);

                resultSummarydocument.Save();
            }
            catch (Exception e)
            {
                Reports.SetupErrorLog(e);
            }
        }
Example #3
0
        private void ExportarDgvAWord(DataGridView dgv, string filename)
        {
            //Creamos el Word
            DocX miWord = DocX.Create(filename);

            //Creamos la tabla
            //Le sumo + 1 para adicionarle el encabezado
            Table miTabla = miWord.AddTable(dgv.RowCount + 1, dgv.ColumnCount);

            miWord.InsertParagraph("Hello Word");

            for (int fila = -1; fila < dgv.RowCount; fila++)
            {
                for (int col = 0; col < dgv.ColumnCount; col++)
                {
                    if (fila == -1) //Es encabezado
                    {
                        //Mediante Bold() cambio a negrita toda la fila
                        miTabla.Rows[0].Cells[col].Paragraphs.First().Append(dgv.Columns[col].HeaderText).Bold();
                    }
                    else //Es otra fila
                    {
                        miTabla.Rows[fila + 1].Cells[col].Paragraphs.First().Append(dgv.Rows[fila].Cells[col].Value.ToString());
                    }
                }
            }

            miWord.InsertTable(miTabla);
            miWord.Save();
        }
Example #4
0
        private static void ExportObjectInDoc(FHXObject obj, DocX doc, int level = 0)
        {
            doc.InsertSection();
            Paragraph p = doc.InsertParagraph(obj.Name).Heading((HeadingType)level).Bold().UnderlineStyle(UnderlineStyle.singleLine);

            p.Alignment = Alignment.left;

            if (obj.Parameters.Count > 0)
            {
                Table t = doc.InsertTable(obj.Parameters.Count, 2);

                int i = 0;
                foreach (FHXParameter par in obj.Parameters)
                {
                    ExportParameterInDoc(par, t, i);
                    i++;
                }
            }


            foreach (FHXObject child in obj.Children)
            {
                ExportObjectInDoc(child, doc, level + 1);
            }
        }
Example #5
0
        ///// <summary>
        ///// 添加概述模块(用于县公司)
        ///// </summary>
        ///// <param name="document"></param>
        ///// <param name="ischild"></param>
        //public virtual void Addintro(DocX document,bool ischild) { }


        /// <summary>
        /// 添加组织机构模块(省公司和市公司)
        /// </summary>
        /// <param name="document"></param>
        public virtual void Addorganization(DocX document, NumoftitleHelper title)
        {
            try
            {
                Paragraph pagebreak = document.InsertParagraph();
                pagebreak.InsertPageBreakAfterSelf();//分页符
                title.Less2Zero();
                var h1_2 = document.InsertParagraph(title.num2title() + "组织机构");
                h1_2.StyleName = "Heading2";
                using (FontFamily fontfamily = new FontFamily("宋体"))
                {
                    h1_2.Color(Color.Black).FontSize(16).Font(fontfamily);
                }
                Table t = table.tableHelper.organizationTable(document, Childcompany, PathManager.getSingleton().GetOrganizationpicPath(CompanyID, false));
                t.Alignment = Alignment.center;
                t.AutoFit   = AutoFit.Contents;
                if (t != null)
                {
                    document.InsertTable(t);
                }
            }
            catch (System.Exception ex)
            {
                LogHelper.WriteLog(typeof(CreateCompany), ex);
            }
        }
Example #6
0
        private void AddTable(CalculationResult calculationResult)
        {
            PageBreak();
            var value = $@"Расчетный состав для {MainWindowViewModel.Instance.Calculation.CountConcrete} м³";

            AddTitle(value);

            var table = _document.AddTable(5, 2);

            table.Design    = TableDesign.TableGrid;
            table.Alignment = Alignment.center;
            table.SetColumnWidth(0, 5024);
            table.SetColumnWidth(1, 5024);

            table.Rows[0].Cells[0].Paragraphs[0].Append("Цемент").Font(_fontFamily.Source).FontSize(_fontSizeText);
            table.Rows[0].Cells[1].Paragraphs[0].Append($@"{calculationResult.CorrectedCementConsumption * MainWindowViewModel.Instance.Calculation.CountConcrete: .##} кг.").Font(_fontFamily.Source).FontSize(_fontSizeText);

            table.Rows[1].Cells[0].Paragraphs[0].Append("Вода").Font(_fontFamily.Source).FontSize(_fontSizeText);
            table.Rows[1].Cells[1].Paragraphs[0].Append($@"{calculationResult.WaterFlowWithRegardToAirContent * MainWindowViewModel.Instance.Calculation.CountConcrete: .##} л.").Font(_fontFamily.Source).FontSize(_fontSizeText);

            table.Rows[2].Cells[0].Paragraphs[0].Append("Песок").Font(_fontFamily.Source).FontSize(_fontSizeText);
            table.Rows[2].Cells[1].Paragraphs[0].Append($@"{calculationResult.TheAmountOfSandDry * MainWindowViewModel.Instance.Calculation.CountConcrete: .##} кг.").Font(_fontFamily.Source).FontSize(_fontSizeText);

            table.Rows[3].Cells[0].Paragraphs[0].Append("Крупный заполнитель").Font(_fontFamily.Source).FontSize(_fontSizeText);
            table.Rows[3].Cells[1].Paragraphs[0].Append($@"{calculationResult.NumberOfCoarseAggregate * MainWindowViewModel.Instance.Calculation.CountConcrete: .##}  кг.").Font(_fontFamily.Source).FontSize(_fontSizeText);

            table.Rows[4].Cells[0].Paragraphs[0].Append($@"Химическая добавка { MainWindowViewModel.Instance.Calculation.Admixtures.Name}").Font(_fontFamily.Source).FontSize(_fontSizeText);
            table.Rows[4].Cells[1].Paragraphs[0].Append($@"{calculationResult.ChemicalAdditive * MainWindowViewModel.Instance.Calculation.CountConcrete: .##}  кг.").Font(_fontFamily.Source).FontSize(_fontSizeText);
            _document.InsertTable(table);
        }
Example #7
0
        /*使用起来就比较麻烦如果这样弄出来
         * DocXClass.addTable(file,3,3,new string[] { "1","2","3"});
         *  DocX document = DocXClass.getDocx(file);
         *  Table t= DocXClass.getTables( document)[0];
         *
         *  DocXClass.setCellvalue( t, 1, 0, "a");
         *  DocXClass.setCellvalue(  t, 1, 1, "b");
         *  DocXClass.setCellvalue( t, 1, 2, "c");
         *  DocXClass.mergeCells( t, true, 2, 0, 2);
         *  DocXClass.setCellvalue( t,2,0,"merge
         *  DocXClass.saveTable(ref document);
         */
        //添加表格,其实可以只需要行列数就行,列标题都可以之后再设置
        public static void addTable(string docx, int row, int col, string[] colHeader)
        {
            if (!File.Exists(docx))
            {
                MessageBox.Show(docx + "文件不存在");
                return;
            }
            if (col > colHeader.Length)
            {
                MessageBox.Show("列标题少于给定的列数目");
                return;
            }
            using (DocX document = DocX.Load(docx))
            {
                // Create a new Table with 2 coloumns and 3 rows.
                Table newTable = document.InsertTable(row, col);

                // Set the design of this Table.
                //newTable.Design = TableDesign.Custom;//传统样式,但是没有表格线
                //newTable.Design = TableDesign.TableNormal;//传统样式,但是没有表格线
                newTable.Design = TableDesign.TableGrid;//传统样式,有了表格线

                // Set the coloumn names.
                for (int i = 0; i < col; i++)
                {
                    newTable.Rows[0].Cells[i].Paragraphs.First().InsertText(colHeader[i], false);
                }


                document.Save();
            }// Release this document from memory.
        }
Example #8
0
            private static Table InsertFixedTable(DocX doc, XElement tableEl)
            {
                XElement colParameters = tableEl.Element("ColumnsParameters");
                int      colCount;

                if (colParameters.Element("ColumnCount") != null)
                {
                    colCount = int.Parse(colParameters.Element("ColumnCount").Value);
                }
                else
                {
                    colCount = colParameters.Element("Columns").Elements().Count();
                }

                Table table = doc.InsertTable(tableEl.Element("Rows").Elements().Count(), colCount);

                table.Design = TableDesign.TableGrid;

                if (colParameters.Element("Columns") != null)
                {
                    byte wIndex = 0;
                    foreach (XElement width in colParameters.Element("Columns").Elements())
                    {
                        table.SetColumnWidth(wIndex, double.Parse(width.Value));
                        wIndex++;
                    }
                }

                return(table);
            }
Example #9
0
        /// <summary>
        /// 添加房地信息总汇模块(作为省公司下级的市公司)
        /// </summary>
        /// <param name="document"></param>
        /// <param name="childcityName"></param>
        public void Addfdxx(DocX document, string childcityName, NumoftitleHelper title)
        {
            try
            {
                Table t = tableHelper.Template_city(document);
                t = tableHelper.inserttable_city(t, lstFM);
                if (t == null)
                {
                    return;
                }
                title.Less2Zero();
                var h1_3 = document.InsertParagraph(title.num2title() + "房地信息总汇");
                h1_3.StyleName = "Heading2";
                using (FontFamily fontfamily = new FontFamily("宋体"))
                {
                    h1_3.Color(Color.Black).FontSize(16).Font(fontfamily);
                }
                //表格描述
                var tbltitle = document.InsertParagraph(childcityName + "房地信息汇总表");
                tbltitle.FontSize(14).Alignment = Alignment.center;

                t.Alignment = Alignment.center;
                t.AutoFit   = AutoFit.Contents;
                document.InsertTable(t);
            }
            catch (Exception ex)
            {
                LogHelper.WriteLog(typeof(CreateCityCompany), ex);
            }
        }
Example #10
0
        ///// <summary>
        ///// 添加市公司的组织机构模块
        ///// </summary>
        ///// <param name="document"></param>
        //public override void Addorganization(DocX document)
        //{
        //    var h1_2 = document.InsertParagraph("组织机构");
        //    h1_2.StyleName = "Heading2";
        //    Table t = table.tableHelper.organizationTable(document, Childcompany, path.pathHelper.GetOrganizationpicPath(CompanyID));
        //    document.InsertTable(t);
        //}

        /// <summary>
        /// 添加组织机构模块(作为省公司下级的市公司)
        /// </summary>
        /// <param name="document"></param>
        /// <param name="childcityID"></param>
        public void Addorganization(DocX document, int childcityID, NumoftitleHelper title)
        {
            List <Companymodel> cchildcityID = DBhelper.GetChildcompany(childcityID);

            Table t = table.tableHelper.organizationTable(document, cchildcityID, PathManager.getSingleton().GetOrganizationpicPath(childcityID, false));//childcountryID

            t.Alignment = Alignment.center;
            t.AutoFit   = AutoFit.Contents;
            if (t == null)
            {
                return;
            }

            title.Less2Zero();
            var h1_2 = document.InsertParagraph(title.num2title() + "组织机构");

            h1_2.InsertPageBreakBeforeSelf();
            h1_2.StyleName = "Heading2";
            using (FontFamily fontfamily = new FontFamily("宋体"))
            {
                h1_2.Color(Color.Black).FontSize(16).Font(fontfamily);
            }

            document.InsertTable(t);
        }
Example #11
0
        private void BuildRow(XlsItem item, DocX document)
        {
            var row      = (XlsRow)item;
            var oldStyle = MergeStyle(item.Style);

            try
            {
                var formatting = GetFormatting();
                if (/*row.Items.Count < 2 &&*/ !row.Items.Exists(i => (i is XlsGroup)))
                {
                    var para = AppendParagraph(document);
                    foreach (var child in row.Items)
                    {
                        AppendParaText(child, para);
                    }
                }
                else
                {
                    var table = document.InsertTable(row.GetRows(), row.GetCols());
                }
            }
            finally
            {
                SetStyle(oldStyle);
            }
        }
Example #12
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);
        }
Example #13
0
        private static void WriteUnitTestStepObjectModification(UnitTestStepObjectModificationViewModel step, DocX doc)
        {
            Paragraph p;

            p           = doc.InsertParagraph();
            p.StyleName = "Heading2";
            p.InsertText(string.Format("Step {0}: {1}", step.ParentIndex + 1, step.DisplayName));

            p           = doc.InsertParagraph();
            p.StyleName = "Heading3";
            p.InsertText(string.Format("Attribute modifications"));

            Table t = doc.InsertTable(step.AttributeChanges.Count + 1, 3);

            t.Alignment = Alignment.left;
            t.Design    = TableDesign.LightListAccent1;

            t.Rows[0].Cells[0].Paragraphs.First().Append("Attribute");
            t.Rows[0].Cells[1].Paragraphs.First().Append("Modification type");
            t.Rows[0].Cells[2].Paragraphs.First().Append("Value");

            for (int i = 0; i < step.AttributeChanges.Count; i++)
            {
                t.Rows[i + 1].Cells[0].Paragraphs.First().Append(step.AttributeChanges[i].Name);
                t.Rows[i + 1].Cells[1].Paragraphs.First().Append(step.AttributeChanges[i].ModificationType.ToString());
                t.Rows[i + 1].Cells[2].Paragraphs.First().Append(step.AttributeChanges[i].ValueChangesString);
            }
        }
Example #14
0
        static void Main(string[] args)
        {
            //EPPlus (excel lib)

            DocX report = DocX.Create("Report.docx", DocumentTypes.Document);


            var paragraph = report.InsertParagraph("YoY Value Report", false,
                                                   new Formatting()
            {
                Bold = true
            });

            report.InsertParagraph();
            report.InsertParagraph();

            var table = report.InsertTable(2, 3);

            table.Rows[0].Cells[0].InsertParagraph("Year");
            table.Rows[0].Cells[1].InsertParagraph("Value");
            table.Rows[0].Cells[2].InsertParagraph("Remarks");

            table.Design = TableDesign.ColorfulList;

            report.Save();
            report.Dispose();
        }
Example #15
0
        public static void GerarTabelaAreaDeEstagio(this DocX document, List <AreaEstagioCurso> areas, int IdArea)
        {
            int   rows = areas.Count();
            Table t    = document.AddTable(rows, 2);

            Formatting format = new Formatting();

            format.Bold = true;
            t.Paragraphs.ForEach(x => x.FontSize(12));
            t.Paragraphs.ForEach(x => x.Font("Arial"));
            t.Alignment = Alignment.center;
            t.AutoFit   = AutoFit.ColumnWidth;
            for (int i = 0; i <= (int)TableBorderType.InsideV; i++)
            {
                t.SetBorder((TableBorderType)i, new Border());
            }

            for (int i = 1; i <= rows; i++)
            {
                int pos = i - 1;
                if (i % 7 == 0)
                {
                    document.InsertSectionPageBreak();
                }

                t.Rows[pos].Cells[1].Paragraphs[0].InsertText(areas[pos].Nome);
                if (areas[pos].Identificador == IdArea)
                {
                    t.Rows[pos].Cells[0].Paragraphs[0].InsertText("X", false, format);
                }
            }

            document.InsertTable(t);
        }
Example #16
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);
        }
Example #17
0
        private void InsertExperiences(Resume resume, DocX doc)
        {
            // 3 experience
            doc.InsertParagraph().AppendLine();
            doc.InsertParagraph(_localizationService.GetResource("Resume.Fields.Experiences", _workContext.Current.WorkingLanguage.Id), false, H2);
            //.AppendLine(line);

            foreach (var exp in resume.Experiences.OrderBy(x => x.DisplayOrder))
            {
                // doc.InsertParagraph().AppendLine();

                var table = doc.AddTable(5, 2);
                table.Design  = TableDesign.TableNormal;
                table.AutoFit = AutoFit.Contents;

                InsertExperienceRow(doc, table, 0, "Resume.Fields.Experiences.Name", exp.GetLocalized(x => x.Name), H4);
                InsertExperienceRow(doc, table, 1, "Resume.Fields.Experiences.Period", exp.GetLocalized(x => x.Period));
                InsertExperienceRow(doc, table, 2, "Resume.Fields.Experiences.Function", exp.GetLocalized(x => x.Function));
                InsertExperienceRow(doc, table, 3, "Resume.Fields.Experiences.City", exp.GetLocalized(x => x.City));
                InsertExperienceRow(doc, table, 4, "Resume.Fields.Experiences.Tasks", exp.GetLocalized(x => x.Tasks));

                doc.InsertTable(table);

                //foreach (var p in exp.Projects)
                //{
                //    doc.InsertParagraph().AppendLine();
                //    doc.InsertParagraph(p.GetLocalized(x => x.Name), false, H4);
                //    doc.InsertParagraph(p.GetLocalized(x => x.Description), false, Normal);
                //    doc.InsertParagraph(p.GetLocalized(x => x.Technology), false, Normal);
                //}
            }
        }
        private void button13_Click(object sender, EventArgs e)
        {
            SaveFileDialog sfd = new SaveFileDialog();

            sfd.AddExtension = true;
            sfd.Filter       = "Word file (*.docx)|*.docx";
            if (sfd.ShowDialog() == DialogResult.OK && sfd.FileName != "")
            {
                if (Path.GetExtension(sfd.FileName) == ".docx")
                {
                    DocX      doc = DocX.Create(sfd.FileName);
                    Paragraph p1  = doc.InsertParagraph();
                    p1.AppendLine("Итоговые результаты расчета").FontSize(14);
                    p1.AppendLine();
                    Table t = doc.AddTable(P.Z + 2, 5);
                    t.Alignment = Alignment.center;
                    t.Rows[0].Cells[0].Paragraphs.First().Append("№ ступени:").FontSize(12);
                    t.Rows[0].Cells[1].Paragraphs.First().Append("H0, кДж / кг").FontSize(12);
                    t.Rows[0].Cells[2].Paragraphs.First().Append("G, кг/с").FontSize(12);
                    t.Rows[0].Cells[3].Paragraphs.First().Append("\u03b7oi").FontSize(12);
                    t.Rows[0].Cells[4].Paragraphs.First().Append("N, МВт").FontSize(12);
                    for (int i = 0; i <= P.Z; i++)
                    {
                        for (int k = 0; k < 5; k++)
                        {
                            t.Rows[i + 1].Cells[k].Paragraphs.First().Append("" + (String)dataGridView1.Rows[i].Cells[k].Value);
                        }
                    }
                    doc.InsertTable(t);
                    doc.Save();
                }
            }
        }
Example #19
0
        private void экспортВWordToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SaveFileDialog sfd = new SaveFileDialog();

            sfd.AddExtension = true;
            sfd.Filter       = "Word file (*.docx)|*.docx";
            if (sfd.ShowDialog() == System.Windows.Forms.DialogResult.OK && sfd.FileName != "")
            {
                if (Path.GetExtension(sfd.FileName) == ".docx")
                {
                    DocX      doc = DocX.Create(sfd.FileName);
                    Paragraph p1  = doc.InsertParagraph();
                    p1.AppendLine("Подробный тепловой расчет ступеней паровой турбины").FontSize(14);
                    p1.AppendLine();
                    Table t = doc.AddTable(j, 3);
                    t.Alignment = Alignment.center;
                    t.SetColumnWidth(0, 200);
                    t.Rows[0].Cells[0].Paragraphs.First().Append("Величина").FontSize(12);
                    t.Rows[0].Cells[1].Paragraphs.First().Append("Единица измерения").FontSize(12);
                    t.Rows[0].Cells[2].Paragraphs.First().Append("Значение").FontSize(12);
                    for (int i = 1; i < j; i++)
                    {
                        for (int k = 0; k < 3; k++)
                        {
                            t.Rows[i].Cells[k].Paragraphs.First().Append("" + (String)DB.Rows[i].Cells[k].Value);
                        }
                    }
                    doc.InsertTable(t);
                    doc.Save();
                }
            }
        }
Example #20
0
        private static Table CreateMainData(DocX doc, string documentType, Vendor vendor, Customer customer, Consumer consumer, DocumentData documentData, PaymentData paymentData)
        {
            var t = doc.AddTable(1, 2);

            t.SetWidthsPercentage(new[] { 50f, 50f }, doc.PageWidth);
            var border = new Border();

            border.Tcbs = BorderStyle.Tcbs_none;
            for (int i = 0; i < 2; i++)
            {
                t.Rows[0].Cells[i].SetBorder(TableCellBorderType.Left, border);
                t.Rows[0].Cells[i].SetBorder(TableCellBorderType.Top, border);
                t.Rows[0].Cells[i].SetBorder(TableCellBorderType.Right, border);
                t.Rows[0].Cells[i].SetBorder(TableCellBorderType.Bottom, border);
            }

            GenerateVendorText(t.Rows[0].Cells[0], vendor);
            GenerateCustomerText(t.Rows[0].Cells[0], customer);
            if (consumer != null)
            {
                GenerateConsumerText(t.Rows[0].Cells[0], consumer);
            }

            GenerateDocumentDataText(t.Rows[0].Cells[1], documentData, documentType);
            GeneratePaymentDataText(t.Rows[0].Cells[1], paymentData);
            doc.InsertTable(t);

            return(t);
        }
Example #21
0
        /// <summary>
        /// Crea la tabla de recursos valiosos
        /// </summary>
        /// <param name="doc"></param>
        /// <param name="empresa"></param>
        private void insertarRecursosValiosos(DocX doc, Empresa empresa)
        {
            List <RecursoValioso> listadoRecursoValioso = MatrizBO.ConsultarRecursosValiosos(empresa.IdEmpresa);
            int cantidadRecursos = listadoRecursoValioso.Count;
            var RVParrafo        = new Novacode.Formatting();

            RVParrafo.FontFamily = new System.Drawing.FontFamily("Calibri");
            RVParrafo.Size       = 12D;
            RVParrafo.Position   = 3;

            Paragraph pParr = doc.InsertParagraph("En este sentido se identifican " + cantidadRecursos + " recursos por encima del promedio, los cuales se convierten en valiosos y se listan a continuación", false, RVParrafo);

            pParr.Alignment = Alignment.left;

            Table tab = doc.AddTable(cantidadRecursos + 1, 2);

            tab.AutoFit   = AutoFit.Contents;
            tab.Alignment = Alignment.center;
            tab.Design    = TableDesign.ColorfulGridAccent1;
            tab.Rows[0].Cells[0].Paragraphs.First().Append("Recurso Valioso");
            tab.Rows[0].Cells[0].Paragraphs.First().Alignment = Alignment.center;
            tab.Rows[0].Cells[0].Paragraphs.First().Bold();
            tab.Rows[0].Cells[1].Paragraphs.First().Append("Observaciones");
            tab.Rows[0].Cells[1].Paragraphs.First().Alignment = Alignment.center;
            tab.Rows[0].Cells[1].Paragraphs.First().Bold();

            for (int i = 0; i < cantidadRecursos; i++)
            {
                RecursoValioso recursoValioso = listadoRecursoValioso[i];
                tab.Rows[i + 1].Cells[0].Paragraphs.First().Append(recursoValioso.NombreRecurso);
            }
            doc.InsertTable(tab);
        }
Example #22
0
        private static Table CreateSignTable(DocX doc)
        {
            var t = doc.AddTable(1, 2);

            t.SetWidthsPercentage(new[] { 50f, 50f }, doc.PageWidth);
            var border = new Border();

            border.Tcbs = BorderStyle.Tcbs_none;

            var formattingBold = new Formatting {
                Bold = true, Size = DefaultSize, FontFamily = Font
            };
            var formattingWithoutBold = new Formatting {
                Bold = false, Size = DefaultSize, FontFamily = Font
            };

            for (int i = 0; i < 2; i++)
            {
                t.Rows[0].Cells[i].SetBorder(TableCellBorderType.Left, border);
                t.Rows[0].Cells[i].SetBorder(TableCellBorderType.Top, border);
                t.Rows[0].Cells[i].SetBorder(TableCellBorderType.Right, border);
                t.Rows[0].Cells[i].SetBorder(TableCellBorderType.Bottom, border);
            }

            var p = t.Rows[0].Cells[0].Paragraphs.First().Append($"........................................................................\r\n{Resource.customerSign}", formattingWithoutBold);

            p.Alignment = Alignment.center;

            p           = t.Rows[0].Cells[1].Paragraphs.First().Append($"........................................................................\r\n{Resource.vendorSign}", formattingWithoutBold);
            p.Alignment = Alignment.center;

            doc.InsertTable(t);
            return(t);
        }
Example #23
0
        // Create Issue Description doc for Evidence (SIT)
        public void CreateXLSX()
        {
            string fp = filepath;

            fp += release + " – Evidence.docx";
            using (DocX document = DocX.Create(@fp)) {
                // Add document info
                string title = release + " – Evidence";
                document.InsertParagraph(title).FontSize(15d).Bold().SpacingAfter(50d).Alignment = Alignment.center;

                // Add a Table into the document and sets its values
                var t1 = document.AddTable(test_names.Count, 2);
                t1.Design    = TableDesign.TableGrid;
                t1.Alignment = Alignment.center;
                t1.Rows[0].Cells[0].FillColor = Color.LightGray;
                t1.Rows[0].Cells[1].FillColor = Color.LightGray;

                for (int i = 0; i < test_names.Count; i++)
                {
                    if (i == 0)
                    {
                        t1.Rows[i].Cells[0].Paragraphs[0].Append(test_names[i]).FontSize(10d).Bold().SpacingBefore(5d).SpacingAfter(5d).Alignment        = Alignment.center;
                        t1.Rows[i].Cells[1].Paragraphs[0].Append(test_descriptions[i]).FontSize(10d).Bold().SpacingBefore(5d).SpacingAfter(5d).Alignment = Alignment.center;
                    }
                    else
                    {
                        t1.Rows[i].Cells[0].Paragraphs[0].Append(test_names[i]).FontSize(8d).KeepLinesTogether(true);
                        t1.Rows[i].Cells[1].Paragraphs[0].Append(test_descriptions[i]).FontSize(8d).KeepLinesTogether(true);
                    }
                }

                t1.AutoFit = AutoFit.Contents;
                document.InsertTable(t1);
                Paragraph p = document.InsertParagraph("\n");

                // Create new table where .zip is embedded
                var t2 = document.AddTable(2, 1);
                t2.Design    = TableDesign.TableGrid;
                t2.Alignment = Alignment.center;
                t2.Rows[0].Cells[0].FillColor = Color.LightGray;
                t2.Rows[0].Cells[0].Paragraphs[0].Append("Before/After Evidence").FontSize(10d).Bold().SpacingBefore(5d).SpacingAfter(5d).Alignment = Alignment.center;
                t2.Rows[1].Cells[0].Paragraphs[0].FontSize(8d).Alignment = Alignment.center;
                document.InsertTable(t2);

                document.Save();
            }
        }
Example #24
0
        private void toolStripMenuItem3_Click(object sender, EventArgs e)
        {
            saveFileDialog1.FileName = "report";
            if (saveFileDialog1.ShowDialog() == DialogResult.Cancel)
            {
                return;
            }

            var conn = new MySqlConnection(Data.connString);

            conn.Open();

            var currentDate  = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss");
            var monthAgoDate = DateTime.Now.AddMonths(-1).ToString("yyyy-MM-dd hh:mm:ss");

            DocX document = DocX.Create(saveFileDialog1.FileName);

            document.InsertParagraph("Отчет").Font("Times New Roman").FontSize(18)
            .Alignment = Alignment.center;
            document.InsertParagraph();

            var countSuccesses =
                conn.QueryFirst <string> (
                    $"select count(*) from link_archive where created between '{monthAgoDate}' and '{currentDate}'");

            document.InsertParagraph($"За последний месяц было создано {countSuccesses} пар");
            document.InsertParagraph();

            var couplesList = conn.Query <forMeeting> (
                $"select concat_ws(' ', A.firstname, A.lastname) as first_person, concat_ws(' ', B.firstname, B.lastname) as second_person from link_archive\njoin archive_person as A on A.id = link_archive.firstP_id\njoin archive_person as B on B.id = link_archive.secondP_id\nwhere created between '{monthAgoDate}' and '{currentDate}'").ToList();

            Table couplesTable = document.AddTable(couplesList.Count + 1, 2);

            couplesTable.Alignment = Alignment.both;
            couplesTable.AutoFit   = AutoFit.ColumnWidth;
            couplesTable.SetWidthsPercentage(new[] { 50.0f, 50.0f });
            couplesTable.Design = TableDesign.TableGrid;

            couplesTable.Rows[0].Cells[0].Paragraphs[0].Append("Первый партнер");
            couplesTable.Rows[0].Cells[1].Paragraphs[0].Append("Второй партнер");

            for (int i = 0; i < couplesList.Count; i++)
            {
                couplesTable.Rows[i + 1].Cells[0].Paragraphs[0].Append(couplesList[i].first_person);
                couplesTable.Rows[i + 1].Cells[1].Paragraphs[0].Append(couplesList[i].second_person);
            }

            document.InsertTable(couplesTable);
            document.InsertParagraph();

            var declinedCount = conn.QueryFirst <string> ($"select count(*) from archive_person\nwhere archive_person.id not in (select id from person) and archive_person.id not in (select firstP_id from link_archive where created between '{monthAgoDate}' and '{currentDate}') and archive_person.id not in (select secondP_id from link_archive where created between '{monthAgoDate}' and '{currentDate}')");

            document.InsertParagraph($"От услуг отказалось {declinedCount} клиентов");

            document.Save();
            conn.Close();

            Process.Start(saveFileDialog1.FileName);
        }
        private void BuildDocumentIndexStyle(List <DirectoryInfo> list)
        {
            var templatetbl = docx.Tables[0];
            var c           = 0;

            var       templaterow    = templatetbl.Rows[0];
            var       ncols          = templaterow.ColumnCount;
            Row       row            = null;
            Table     tbl            = null;
            Paragraph alphaParagraph = null;

            foreach (var pg in docx.Paragraphs)
            {
                if (pg.Text.Contains("{lastnamestartswith}"))
                {
                    alphaParagraph = pg;
                    break;
                }
            }

            var alphaindex = "@";

            foreach (var m in list)
            {
                if (m.Person.LastName[0] != alphaindex[0])
                {
                    tbl?.RemoveRow(0);
                    var pg = docx.InsertParagraph(alphaParagraph);
                    pg.KeepWithNextParagraph();
                    alphaindex = m.Person.LastName.Substring(0, 1);
                    pg.ReplaceText("{lastnamestartswith}", alphaindex);
                    tbl = docx.InsertTable(templatetbl);
                    c   = 0;
                }
                Debug.Assert(tbl != null, "tbl != null");
                if (c == 0) // start a new row
                {
                    row = tbl.InsertRow(templaterow);
                    row.BreakAcrossPages = false;
                    tbl.Rows.Add(row);
                }
                Debug.Assert(row != null, "row != null");
                var cell = row.Cells[c];
                DoCellReplacements(cell, m);
                if (++c == ncols)
                {
                    c = 0; // start a new row
                }
            }
            while (c > 0 && c < ncols && row != null)
            {
                DoEmptyCell(row.Cells[c++]);
            }

            tbl?.RemoveRow(0);                              // remove first row from last table worked on
            docx.RemoveParagraph(alphaParagraph);           // remove the alphaParagraph template
            docx.Tables[0].Remove();                        // remove the template table
            docx.Paragraphs[0].Remove(trackChanges: false); // remove the empty paragraph after the template table
        }
Example #26
0
        private void button1_Click(object sender, EventArgs e)
        {
            //创建文档
            using (DocX document = DocX.Create(@"HelloWorld.docx"))
            {
                //插入段落
                Paragraph p = document.InsertParagraph();

                //段落加入文本,定义格式
                p.Append("Hello World!")              //内容
                .Font(new Xceed.Words.NET.Font("宋体")) //字体格式
                .FontSize(20)                         //字体大小
                .Color(Color.Blue)                    //字体颜色
                .Bold()
                .Alignment = Alignment.center;        //字体对其方式

                p = document.InsertParagraph();       //创建段落
                p.Append("CHINA")
                .Font(new Xceed.Words.NET.Font("微软雅黑"))
                .FontSize(18)
                .Color(Color.Red);

                //插入表格4x4,使用addtable后再inserttable
                var table1 = document.AddTable(9, 4);
                table1.Design = TableDesign.TableGrid;

                for (int i = 0; i < 9; i++)
                {
                    for (int k = 0; k < 4; k++)
                    {
                        table1.Rows[i].Cells[k].Paragraphs.First().InsertText(string.Format("第{0}行,第{1}列", i, k));
                    }
                }
                //合并单元格
                table1.MergeCellsInColumn(0, 0, 1);
                //////水平合并(合并第1行的第1、2个单元格)
                //table1.ApplyHorizontalMerge(0, 0, 1);
                //table1.Rows[0].Cells[0].Paragraphs[0].ChildObjects.Add(table.Rows[0].Cells[1].Paragraphs[0].ChildObjects[0]);

                ////垂直合并(合并第1列的第3、4个单元格)
                //table.ApplyVerticalMerge(0,2, 3);
                //table.Rows[2].Cells[0].Paragraphs[0].ChildObjects.Add(table.Rows[3].Cells[0].Paragraphs[0].ChildObjects[0]);


                document.InsertTable(table1);

                //追加行
                document.Tables[0].InsertRow().Cells[1].Paragraphs.First().InsertText("新添11加的行");
                //插入图片
                p = document.InsertParagraph();
                Xceed.Words.NET.Image image = document.AddImage(@"1.jpg");
                Picture pic = image.CreatePicture();
                p.InsertPicture(pic);
                p.Alignment = Alignment.right;
                //保存文档
                document.Save();
            }
            MessageBox.Show("Done!");
        }
Example #27
0
        private DocX addHeaderTable(DocX _doc)
        {
            DocX   doc            = _doc;
            var    columnWidths   = new float[] { 270, 190 };
            Table  headerTable    = doc.AddTable(15, columnWidths.Length);
            Border lastCellBorder = new Border(BorderStyle.Tcbs_single, BorderSize.one, 0, System.Drawing.Color.Black);

            ConfigHandler configHandler = new ConfigHandler();
            Formatting    format        = getHeaderFormat();
            Font          font          = null;
            string        fontName      = configHandler.read(mainViewModel, "invoiceStandardFont");

            if (!string.IsNullOrEmpty(fontName))
            {
                font = new Font(fontName);
            }
            else
            {
                font = new Font("Times New Roman");
            }

            headerTable.Alignment = Alignment.center;
            headerTable.SetWidths(columnWidths);
            headerTable.SetWidths(columnWidths);
            headerTable.Design  = TableDesign.TableGrid;
            headerTable.AutoFit = AutoFit.ColumnWidth;
            headerTable         = setBorder(headerTable);

            headerTable.Rows[0].Cells[1].Paragraphs[0].Append(mainViewModel.profileFirstName + " " + mainViewModel.profileLastName, format);
            headerTable.Rows[1].Cells[0].Paragraphs[0].Append(mainViewModel.customerCompanyName, format);
            headerTable.Rows[1].Cells[1].Paragraphs[0].Append(mainViewModel.profileAddress + " " + mainViewModel.profileAddressNumber, format);
            headerTable.Rows[2].Cells[0].Paragraphs[0].Append(mainViewModel.customerAddress + " " + mainViewModel.customerAddressNumber, format);
            headerTable.Rows[2].Cells[1].Paragraphs[0].Append(mainViewModel.profilePostalCode + " " + mainViewModel.profileCityName, format);
            headerTable.Rows[3].Cells[0].Paragraphs[0].Append(mainViewModel.customerPostalCode + " " + mainViewModel.customerCityName, format);
            headerTable.Rows[3].Cells[1].Paragraphs[0].Append("Tel: " + mainViewModel.profileTelephoneNumber, format);
            headerTable.Rows[4].Cells[1].Paragraphs[0].Append("Mobil: " + mainViewModel.profileMobileNumber, format);
            headerTable.Rows[5].Cells[1].Paragraphs[0].Append("Fax: " + mainViewModel.profileFaxNumber, format);
            headerTable.Rows[6].Cells[1].Paragraphs[0].Append("E-Mail: " + mainViewModel.profileEMailAddress, format);

            headerTable.Rows[7].Cells[1].Paragraphs[0].Append("", format); //empty

            headerTable.Rows[8].Cells[1].Paragraphs[0].Append(mainViewModel.profileBankName, format);
            headerTable.Rows[9].Cells[1].Paragraphs[0].Append("Konto Nr.: " + mainViewModel.profileBankAccountNumber, format);
            headerTable.Rows[10].Cells[1].Paragraphs[0].Append("BLZ: " + mainViewModel.profileBankCodeNumber, format);
            headerTable.Rows[11].Cells[1].Paragraphs[0].Append("IBAN: " + mainViewModel.profileIBAN, format);
            headerTable.Rows[12].Cells[1].Paragraphs[0].Append("BIC: " + mainViewModel.profileBankCodeNumber, format);

            headerTable.Rows[13].Cells[1].Paragraphs[0].Append("", format); //empty

            headerTable.Rows[14].Cells[0].SetBorder(TableCellBorderType.Bottom, lastCellBorder);
            headerTable.Rows[14].Cells[1].Paragraphs[0].Append(mainViewModel.profileCityName + ", den " + mainViewModel.invoiceDate, format);
            headerTable.Rows[14].Cells[1].SetBorder(TableCellBorderType.Bottom, lastCellBorder);

            doc.InsertTable(headerTable);

            return(doc);
        }
Example #28
0
        private void toolStripMenuItem2_Click(object sender, EventArgs e)
        {
            var companybik = Interaction.InputBox("Введите БИК компании: ");

            if (companybik == "")
            {
                return;
            }

            saveFileDialog1.FileName = "list";
            saveFileDialog1.ShowDialog();
            var path = saveFileDialog1.FileName;

            var conn = new MySqlConnection(Information.connString);

            conn.Open();

            DocX document = DocX.Create(path);

            document.InsertParagraph("Список должностей").Font("Times New Roman").FontSize(18).Alignment = Alignment.left;
            document.InsertParagraph();

            var count        = conn.QueryFirst <string> ($"select count(*) from position where company_id = {companybik}");
            var positionList = conn.Query <Position> ($"select name, payment, conditions, requirements from position where company_id = {companybik}").ToList();

            Table mainTable = document.AddTable(Convert.ToInt32(count) + 1, 4);

            mainTable.Alignment = Alignment.both;
            mainTable.AutoFit   = AutoFit.ColumnWidth;
            mainTable.SetWidthsPercentage(new[] { 25.0f, 25.0f, 25.0f, 25.0f });
            mainTable.Design = TableDesign.None;

            mainTable.Rows[0].Cells[0].Paragraphs[0].Append("Название должнолсти");
            mainTable.Rows[0].Cells[1].Paragraphs[0].Append("Оплата");
            mainTable.Rows[0].Cells[2].Paragraphs[0].Append("Условия");
            mainTable.Rows[0].Cells[3].Paragraphs[0].Append("Требования");

            for (int i = 0; i < Convert.ToInt32(count); i++)
            {
                mainTable.Rows[i + 1].Cells[0].Paragraphs[0].Append(positionList[i].name);
                mainTable.Rows[i + 1].Cells[1].Paragraphs[0].Append(positionList[i].payment);
                mainTable.Rows[i + 1].Cells[2].Paragraphs[0].Append(positionList[i].conditions);
                mainTable.Rows[i + 1].Cells[3].Paragraphs[0].Append(positionList[i].requirements);
            }

            document.InsertTable(mainTable);

            document.InsertParagraph();
            var phone = conn.QueryFirstOrDefault <string> ($"select phone from company where bik = {companybik}");

            document.InsertParagraph($"Звонить по телефону {phone}");

            document.Save();
            conn.Close();

            Process.Start(path);
        }
        private static void InsertWaresTable(DocX doc, out Table waresTable, out Row r)
        {
            waresTable = doc.InsertTable(1, 6);
            waresTable.TableCaption = "WARES_TABLE";

            r = waresTable.Rows.First();

            FillWaresTableInformationRow(waresTable, r);
        }
Example #30
0
        /// <summary>
        /// Add a Table in a document where its columns will have a specific width. In addition,
        /// the left margin of the row cells will be removed for all rows except the first.
        /// Finally, a blank border will be set for the table's top and bottom borders.
        /// </summary>
        public static void ColumnsWidth()
        {
            Console.WriteLine("\tColumnsWidth()");

            // Create a document
            using (DocX document = DocX.Create(TableSample.TableSampleOutputDirectory + @"ColumnsWidth.docx"))
            {
                // Add a title
                document.InsertParagraph("Columns width").FontSize(15d).SpacingAfter(50d).Alignment = Alignment.center;

                // Insert a title paragraph.
                var p = document.InsertParagraph("In the following table, the cell's left margin has been removed for rows 2-6 as well as the top/bottom table's borders.").Bold();
                p.Alignment = Alignment.center;
                p.SpacingAfter(40d);

                // Add a table in a document of 1 row and 3 columns.
                var columnWidths = new float[] { 100f, 300f, 200f };
                var t            = document.InsertTable(1, columnWidths.Length);

                // Set the table's column width and background
                t.SetWidths(columnWidths);
                t.Design  = TableDesign.TableGrid;
                t.AutoFit = AutoFit.Contents;

                var row = t.Rows.First();

                // Fill in the columns of the first row in the table.
                for (int i = 0; i < row.Cells.Count; ++i)
                {
                    row.Cells[i].Paragraphs.First().Append("Data " + i);
                }

                // Add rows in the table.
                for (int i = 0; i < 5; i++)
                {
                    var newRow = t.InsertRow();

                    // Fill in the columns of the new rows.
                    for (int j = 0; j < newRow.Cells.Count; ++j)
                    {
                        var newCell = newRow.Cells[j];
                        newCell.Paragraphs.First().Append("Data " + i);
                        // Remove the left margin of the new cells.
                        newCell.MarginLeft = 0;
                    }
                }

                // Set a blank border for the table's top/bottom borders.
                var blankBorder = new Border(BorderStyle.Tcbs_none, 0, 0, Color.White);
                t.SetBorder(TableBorderType.Bottom, blankBorder);
                t.SetBorder(TableBorderType.Top, blankBorder);

                document.Save();
                Console.WriteLine("\tCreated: ColumnsWidth.docx\n");
            }
        }