Exemple #1
0
        public void GetTableCellText()
        {
            using (var doc = WordprocessingDocument.Open(TemplatePath, false))
            {
                var table = new WordDocumentTable(doc);
                table.Select("Table1");
                var cell = new WordDocumentTableCell(table.Table);
                cell.Select(3, 2);
                var txt = cell.Text;

                Assert.AreEqual(txt, "TextInColumn");
            }
        }
Exemple #2
0
        public void GetTableCellProperties()
        {
            using (var doc = WordprocessingDocument.Open(TemplatePath, false))
            {
                var table = new WordDocumentTable(doc);
                table.Select("Table1");
                var cell = new WordDocumentTableCell(table.Table);
                cell.Select(1, 1);
                var cp = (TableCellProperties)cell.CellProperties;

                Assert.IsNotNull(cp);
                Assert.AreEqual(cp.TableCellWidth.Width.ToString(), "4809");
            }
        }
Exemple #3
0
        public void CopyRow()
        {
            using (var doc = WordprocessingDocument.Open(TemplatePath, true, new OpenSettings {
                AutoSave = false
            }))
            {
                var table = new WordDocumentTable(doc);
                table.Select("Table1");

                table.Rows.Copy();
                var cell = table.Cell(4, 2);

                Assert.AreEqual(cell.Text, "TextInColumn");
            }
        }
Exemple #4
0
        public void CanAddRow()
        {
            using (var doc = WordprocessingDocument.Open(TemplatePath, true, new OpenSettings {
                AutoSave = false
            }))
            {
                var table = new WordDocumentTable(doc);
                table.Select("Table1");

                table.Rows.Add();
                var cell = table.Cell(4, 2);

                Assert.IsNotNull(cell);
            }
        }
        public void GetCopyOfTableToTable()
        {
            using (var doc = WordprocessingDocument.Open(TemplatePath, true, new OpenSettings {
                AutoSave = false
            }))
            {
                var destTable = new WordDocumentTable(doc);
                destTable.Select("TableForCopy");
                var sourceTable = new WordDocumentTable(doc);
                sourceTable.Select("Table2");

                sourceTable.GetCopyOf(destTable);

                Assert.AreEqual(sourceTable.Cell(5, 1).Text, "Вид инструктажа");
            }
        }
        public void CopyTableToTable()
        {
            using (var doc = WordprocessingDocument.Open(TemplatePath, true, new OpenSettings {
                AutoSave = false
            }))
            {
                var destTable = new WordDocumentTable(doc);
                destTable.Select("TableForCopy");
                var sourceTable = new WordDocumentTable(doc);
                sourceTable.Select("Table2");

                sourceTable.CopyTo(destTable);

                Assert.AreEqual(destTable.Cell(9, 1).Text, "Годен\r\nЗдоров\r\nМолод");
            }
        }
        public void CanCopyRowByIndex()
        {
            using (var doc = WordprocessingDocument.Open(TemplatePath, true, new OpenSettings {
                AutoSave = false
            }))
            {
                var table = new WordDocumentTable(doc);
                table.Select("Table1");
                var rows = new WordDocumentTableRows(table);

                rows.CopyRow(2);
                var cell = table.Cell(4, 3);

                Assert.AreEqual(cell.Text, "Количество");
            }
        }
Exemple #8
0
        public void SetCellText()
        {
            using (var doc = WordprocessingDocument.Open(TemplatePath, true, new OpenSettings {
                AutoSave = false
            }))
            {
                var table = new WordDocumentTable(doc);
                table.Select("Table1");
                var          cell = table.Cell(3, 2);
                const string val  = "New Text";

                cell.Text = val;

                Assert.AreEqual(cell.Text, val);
            }
        }
        public void CanCopyRow()
        {
            using (var doc = WordprocessingDocument.Open(TemplatePath, true, new OpenSettings {
                AutoSave = false
            }))
            {
                var table = new WordDocumentTable(doc);
                table.Select("Table1");
                var rows = new WordDocumentTableRows(table);
                var cnt  = rows.Count;

                var newRow = rows.Copy();

                Assert.IsNotNull(newRow);
                Assert.AreEqual(cnt + 1, rows.Count);
            }
        }
        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"));
            }
        }
        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);
            }
        }
Exemple #12
0
        public void SetTableProperties()
        {
            using (var doc = WordprocessingDocument.Open(TemplatePath, true, new OpenSettings {
                AutoSave = false
            }))
            {
                var table = new WordDocumentTable(doc);
                table.Select("Table1");
                var ntp = new TableProperties(
                    new TableCaption
                {
                    Val = "Table2"
                });
                table.TableProperties = ntp;
                var tp = (TableProperties)table.TableProperties;

                Assert.IsNotNull(tp);
                Assert.AreEqual(tp.TableCaption.Val.ToString(), "Table2");
            }
        }
        public void GetCopyOfTableToFooter()
        {
            using (var doc = WordprocessingDocument.Open(TemplatePath, true, new OpenSettings {
                AutoSave = false
            }))
            {
                var table = new WordDocumentTable(doc);
                table.Select("Table1");
                var footer = doc.MainDocumentPart.FooterParts
                             .Select(f => f.Footer)
                             .LastOrDefault();

                var source = new PrintObject(table.Table);
                var dest   = new PrintObject(footer);

                Assert.AreEqual(footer.Descendants <Table>().Count(), 0);

                dest.GetCopyOf(source);

                Assert.AreEqual(footer.Descendants <Table>().Count(), 1);
            }
        }
Exemple #14
0
        public void SetTableCellProperties()
        {
            using (var doc = WordprocessingDocument.Open(TemplatePath, true, new OpenSettings {
                AutoSave = false
            }))
            {
                var table = new WordDocumentTable(doc);
                table.Select("Table1");
                var cell = new WordDocumentTableCell(table.Table);
                cell.Select(1, 1);

                var ncp = new TableCellProperties(
                    new TableCellWidth
                {
                    Type  = TableWidthUnitValues.Dxa,
                    Width = "2400"
                });
                cell.CellProperties = ncp;
                var cp = (TableCellProperties)cell.CellProperties;

                Assert.IsNotNull(cp);
                Assert.AreEqual(cp.TableCellWidth.Width.ToString(), "2400");
            }
        }