public WordDocumentTable(WordprocessingDocument doc, Table table)
 {
     Doc           = doc;
     InternalTable = table;
     XmlElement    = table;
     Name          = GetTableName();
     Rows          = new WordDocumentTableRows(this);
 }
        public void CanGetRow()
        {
            using (var doc = WordprocessingDocument.Open(TemplatePath, false))
            {
                var table = new WordDocumentTable(doc);
                table.Select("Table1");
                var rows = new WordDocumentTableRows(table.Table);

                Assert.IsNotNull(rows.Item(1));
            }
        }
        public void GetRowsCount()
        {
            using (var doc = WordprocessingDocument.Open(TemplatePath, false))
            {
                var table = new WordDocumentTable(doc);
                table.Select("Table1");
                var rows = new WordDocumentTableRows(table.Table);

                Assert.AreEqual(rows.Count, 3);
            }
        }
        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, "Количество");
            }
        }
        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);
            }
        }
 private bool TryAppendCopyOfTable(IPrintObject sourcePrintObject)
 {
     try
     {
         var tbl = sourcePrintObject as IWordDocumentTable;
         if (tbl != null)
         {
             CopyTableToTable((Table)tbl.Table, InternalTable);
             Rows = new WordDocumentTableRows(this);
             return(true);
         }
         return(false);
     }
     catch (Exception)
     {
         return(false);
     }
 }
        public void SetTextInNewRow()
        {
            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.Add();
                var          cell = table.Cell(4, 1);
                const string val  = "New Text";

                cell.Text = val;

                Assert.AreEqual(cell.Text, val);
            }
        }
        public bool Select(string name)
        {
            Table table;

            if (TryFindByName(name, out table))
            {
                InternalTable = table;
            }
            else
            {
                if (TryFindByLocalName(name, out table))
                {
                    InternalTable = table;
                }
                else
                {
                    return(false);
                }
            }
            XmlElement = InternalTable;
            Name       = GetTableName();
            Rows       = new WordDocumentTableRows(this);
            return(true);
        }