Beispiel #1
0
        public void AddTable()
        {
            try
            {

                OXMLDocWrap doc = new OXMLDocWrap();
                doc.OpenDocument(@"..\..\test\TestModule.docx");

                OXMLTableStyleWrap tStyle = doc.TableStyles.Find(x => x.StyleID =="a5");
                OXMLTableWrap table = new OXMLTableWrap(4, 7, tStyle, null);

                table.GetCell(2, 2).TextAlignmentV = TextAlignmentVert.Bottom;
                table.GetCell(2, 2).paragraph.TextAlignmentH = TextAlignmentHoriz.Right;
                table.GetCell(2, 2).paragraph.AddText("YES");

                table.Rows[1].Height = 2.5F;
                table.Columns[1].Width = 2.5F;

                //if (table.CountColumns != 4) Assert.Fail("Count columns failt: " + table.CountColumns);
                //if (table.CountRows != 4) Assert.Fail("Count Rows failt: " + table.CountRows);

                //table.SetRowHeight(1, 2);
                //table.SetColumnWidth(1, 3);

                doc.AddTable(table);

                doc.CloseDocument();

            } catch (Exception e)
            {
                Assert.Fail("EXCEPT: " + e.Message);
            }

            Assert.Pass();
        }
Beispiel #2
0
        private int CurrentTechSection; //текущий нумерованный раздел техничекого текста

        #endregion Fields

        #region Constructors

        public TechDoc3(string TemplateFilename)
        {
            CurrentTechSection = 0;
            CurrentTechLine = 0;
            ItemSectionFormat = "{0}. ";
            ItemLineFormat = "{0}.{1}. ";

            doc = new OXMLDocWrap();
            doc.OpenDocument(TemplateFilename);

            //получение/настройка стилей
            SectionStyle = doc.ParagraphStyles.Find(x => x.StyleNAME =="heading 1");
            //SectionStyle.FontColor = "";	//черный
            //SectionStyle.FontName = "Times New Roman";
            //SectionStyle.FontSize = "16";

            NormalStyle = doc.ParagraphStyles.Find(x => x.StyleNAME =="Normal");
            //NormalStyle.FontColor = "";		//черный
            //NormalStyle.FontName = "Times New Roman";
            //NormalStyle.FontSize = "12";

            TableNormalStyle = doc.TableStyles.Find(x => x.StyleID =="a5");
            //список таблиц документа
            TablesList = new Dictionary<string, OXMLTableWrap>();
            //список литературы
            BiblioList = new List<BiblioSource>();
        }
Beispiel #3
0
        public void AddSimpleTextLine()
        {
            OXMLDocWrap doc = new OXMLDocWrap();
            doc.OpenDocument(@"..\..\test\TestModule.docx");

            OXMLParagraphWrap par = new OXMLParagraphWrap();
            doc.ParagraphStyles[0].FontName = "Arial";
            par.SetStyle(doc.ParagraphStyles[0]);
            par.AddText("NEW3");

            par.AddTextRedHighlight("redS");

            doc.AddParagraph(par);

            doc.CloseDocument();

            Assert.Pass();
        }
Beispiel #4
0
        public void SetDocProperty()
        {
            try
            {

                OXMLDocWrap doc = new OXMLDocWrap();
                doc.OpenDocument(@"..\..\test\TestModule.docx");

                doc.SetDocTextProperty("ZKODocType", "PROP_DocType_007");
                doc.SetDocTextProperty("ZKODesignation", "PROP_Dignation_007");
                //doc.RefreshDocTexProperty();
                doc.RefreshAutoDocTextProperty(false);

                doc.CloseDocument();

            } catch (Exception e)
            {
                Assert.Fail("EXCEPT: " + e.Message);
            }

            Assert.Pass();
        }
Beispiel #5
0
        public void TestMathFormulaWithRef()
        {
            try
            {

                OXMLDocWrap doc = new OXMLDocWrap();
                doc.OpenDocument(@"..\..\test\TestModule.docx");

                    OXMLTableWrap table = new OXMLTableWrap(2, 1, doc.TableStyles.Find(x => x.StyleID =="a5"), null);

                    table.Rows[0].setHeightWithRule(2, OXMLHeightRuleValues.Auto);

                    table.GetCell(0, 0).paragraph.TextAlignmentH = TextAlignmentHoriz.Center;
                    table.GetCell(1, 0).paragraph.TextAlignmentH = TextAlignmentHoriz.Center;

                    table.Columns[0].Width = 16.0f;
                    table.Columns[1].Width = 1.0f;

                    table.GetCell(0, 0).margins.LeftMargin = 12;
                    doc.AddMathFormulaToParagraph(table.GetCell(0, 0).paragraph, @"F=\SUP((\FRAC(1)(2)))(4)+1");

                    table.GetCell(1, 0).paragraph.AddText("(1)");

                    var param = new OXMLTableBorderParam();
                    param.bVal = "None";
                    param.bColor = "auto";
                    param.bSpace = 0;
                    param.bSize = 0;

                    table.borders.AllBorders = param;
                    doc.AddTable(table);

                doc.CloseDocument();

            } catch (Exception e)
            {
                Assert.Fail("EXCEPT: " + e.Message);
            }

            Assert.Pass();
        }
Beispiel #6
0
        public void TestMathFormula()
        {
            try
            {

                OXMLDocWrap doc = new OXMLDocWrap();
                doc.OpenDocument(@"..\..\test\TestModule.docx");

                //doc.AddMathFormula(@"F=\SUP(\SUB(2)(6))(4)+1");
                doc.AddMathFormula(@"F=\SUP((\FRAC(1)(2)))(4)+1");

                doc.CloseDocument();

            } catch (Exception e)
            {
                Assert.Fail("EXCEPT: " + e.Message);
            }

            Assert.Pass();
        }
Beispiel #7
0
        public void TagsTest()
        {
            try
            {

                OXMLDocWrap doc = new OXMLDocWrap();
                doc.OpenDocument(@"..\..\test\TestModule.docx");

                doc.SetParentBlockToAdd("PlaceTag001");

                var par = new OXMLParagraphWrap();

                doc.AddMathFormulaToParagraph(par, @"\SUB(12)(2)");
                doc.AddParagraph(par);

                doc.CloseDocument();

            } catch (Exception e)
            {
                Assert.Fail("EXCEPT: " + e.Message);
            }

            Assert.Pass();
        }