Пример #1
0
        public void CopyBookmark()
        {
            using (var doc = WordprocessingDocument.Open(TemplatePath, true, new OpenSettings {
                AutoSave = false
            }))
            {
                var table = new WordDocumentTable(doc);
                table.Select("Table1");
                var bookmarks = new WordDocumentBookmarks(doc);
                var bkm       = new WordDocumentBookmark(doc);
                bkm.Select("order_caption");
                var dest = new PrintObject(table.Table);

                Assert.IsFalse(bookmarks.Exists("order_caption_copy"));

                bkm.CopyTo(dest);

                Assert.IsTrue(bookmarks.Exists("order_caption_copy"));
            }
        }
Пример #2
0
        public void CopyTableToBookmark()
        {
            using (var doc = WordprocessingDocument.Open(TemplatePath, true, new OpenSettings {
                AutoSave = false
            }))
            {
                var table = new WordDocumentTable(doc);
                table.Select("TableForCopy");
                var bookmarks = new WordDocumentBookmarks(doc);
                var bkm       = new WordDocumentBookmark(doc);
                bkm.Select("table_copy");

                Assert.IsNull(bookmarks.Item("table_copy").Table);

                bkm.GetCopyOf(table);

                Assert.IsFalse(string.IsNullOrEmpty(bkm.Text));
                Assert.IsNotNull(bkm.Table);
            }
        }