Beispiel #1
0
 private void CreateRows(int rowCount, int colCount)
 {
     for (var i = 0; i < rowCount; i++)
     {
         var row = new WtRow() { OwnerTable = this };
         for (var j = 0; j < colCount; j++)
         {
             var cell = row.CreateCells();
             cell.Width = row.Width/colCount;
             cell.Height = row.Height;
             row.Add(cell);
         }
         Rows.Add(row);
         row.SetCellsRelation();
         //this.Height += row.Height;
     }
 }
Beispiel #2
0
        public DTable Xml2Object(XmlElement xmlElement)
        {
            if (!"table".Equals(xmlElement.Name)) return this;

            Width = Convert.ToInt32(xmlElement.GetAttribute("width"));
            Height = Convert.ToInt32(xmlElement.GetAttribute("height"));

            var rowElements = xmlElement.ChildNodes;
            foreach (XmlNode rowNode in rowElements)
            {
                if (!"tRow".Equals(rowNode.Name)) continue;
                var rowElement = (XmlElement) rowNode;
                var row = new WtRow
                    {
                        Width = Convert.ToInt32(rowElement.GetAttribute("width")),
                        Height = Convert.ToInt32(rowElement.GetAttribute("height")),
                        OwnerTable = this
                    };

                var cellElements = rowElement.ChildNodes;
                foreach (XmlNode cellNode in cellElements)
                {
                    if(!"tCell".Equals(cellNode.Name)) continue;
                    var cellElement = (XmlElement) cellNode;
                    var cell = new WtCell
                        {
                            OwnerTable = this,
                            OwnerRow = row,
                            OwnerDocument = {Context = OwnerDocument.Context}
                        };
                    cell.Xml2Object(cellElement);
                    row.Add(cell);
                }
                row.SetCellsRelation();
                Rows.Add(row);
            }
            SetRowsRelation();
            return this;
        }