コード例 #1
0
        public void CanSelectCell()
        {
            using (var doc = WordprocessingDocument.Open(TemplatePath, false))
            {
                var table = new WordDocumentTable(doc);
                table.Select("Table1");
                var cell = new WordDocumentTableCell(table.Table);

                Assert.IsTrue(cell.Select(1, 1));
            }
        }
コード例 #2
0
        public void GetTableEmptyCellText()
        {
            using (var doc = WordprocessingDocument.Open(TemplatePath, false))
            {
                var table = new WordDocumentTable(doc);
                table.Select("Table1");
                var cell = new WordDocumentTableCell(table.Table);
                cell.Select(3, 1);
                var txt = cell.Text;

                Assert.IsTrue(string.IsNullOrEmpty(txt));
            }
        }
コード例 #3
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");
            }
        }
コード例 #4
0
 private bool TryGetCell(int rowNum, int colNum, out IWordDocumentTableCell tableCell)
 {
     if (Table != null)
     {
         var cell = new WordDocumentTableCell(this);
         if (cell.Select(rowNum, colNum))
         {
             tableCell = cell;
             return(true);
         }
     }
     tableCell = null;
     return(false);
 }
コード例 #5
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");
            }
        }
コード例 #6
0
        public void SetTableCellText()
        {
            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(3, 2);
                const string val = "New Text";

                cell.Text = val;

                Assert.AreEqual(cell.Text, val);
            }
        }
コード例 #7
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");
            }
        }