Пример #1
0
        public void TestTemplate()
        {
            string xmlTemplate = Resources.ReleaseNotesTemplate.ToString();

            //string xmlTemplate = Util.readFile("src/test/resources/ReleaseNotesTemplate.doc");

            xmlTemplate = ReplacePh(xmlTemplate, "phCompanyName", "EasyWorld - coding for fun pty");
            xmlTemplate = ReplacePh(xmlTemplate, "phEnv", "Production");
            xmlTemplate = ReplacePh(xmlTemplate, "phVersion", "1.0 beta");
            xmlTemplate = ReplacePh(xmlTemplate, "phProjectLeader", "Leonardo Correa");

            Table tbl = new Table();

            tbl.AddTableEle(TableEle.TH, "Jira Number", "Description");

            tbl.AddTableEle(TableEle.TD, "J2W-1234", "Read Templates nicelly");
            tbl.AddTableEle(TableEle.TD, "J2W-9999", "Make Java2word funky!!!");

            xmlTemplate = ReplacePh(xmlTemplate, "phTableIssues", tbl.Content);

            Paragraph p01 = Paragraph.With("1) Stop the server").Create();
            Paragraph p02 = Paragraph.With("2) Run the script to deploy the app xxx").Create();
            Paragraph p03 = Paragraph.With("3) Start the server").Create();
            Paragraph p04 = Paragraph.With("4) Hope for the best").Create();

            string instructions = p01.Content + p02.Content + p03.Content + p04.Content;

            //Workaround: phInstructions is already inside a 'text' fragment.
            //If you know the template, you can remove the whole element and add all Paragraphs
            //* Table above doesn't need workaround because table can be normally inside a paragraph.
            xmlTemplate = ReplacePh(xmlTemplate, "<w:t>phInstructions</w:t>", instructions);

            xmlTemplate = ReplacePh(xmlTemplate, "phDateTime", new DateTime().ToString());

            //TestUtils.createLocalDoc(xmlTemplate);
        }