예제 #1
0
        public WordTableRowDef AddRow()
        {
            var row = new WordTableRowDef();

            _rows.Add(/*rowNo, */ row);
            return(row);
        }
예제 #2
0
        private void AddTableCell(WordTableRowDef rowDef, XmlNode cell, ref int colNo)
        {
            var oldStyle = new ContentStyle(_style);

            try
            {
                SetSectionStyle(cell);
                var cellDef = rowDef.AddCell(colNo);
                cellDef.Style = _style;

                if (!cell.HasChildNodes)
                {
                    cellDef.AddText(cell.InnerText, _style);
                }
                else
                {
                    foreach (XmlNode child in cell.ChildNodes)
                    {
                        AddTextOrField(cellDef, child);
                    }
                }
                colNo++;
            }
            finally
            {
                _style.Assign(oldStyle);
            }
        }
예제 #3
0
        public WordTableRowDef InsertRow(int rowNo)
        {
            if (_rows.Count > rowNo)
            {
                return(_rows[rowNo]);
            }

            var row = new WordTableRowDef();

            _rows.Add(/*rowNo, */ row);
            return(row);
        }
        private void AddTableRowCell(WordTableDef table, WordTableRowDef row, XlsItem item, ref int rowNo, ref int colNo)
        {
            var field = item as XlsDataField;

            if (field != null)
            {
                var cell = row.AddCell(colNo);
                cell.Style   = field.Style;
                cell.ColSpan = 1;
                var val  = ((XlsCell)item).GetValue();
                var type = field.Field.GetDataType();
                var s    = String.Empty;
                if (val != null)
                {
                    switch (type)
                    {
                    case BaseDataType.Text:
                        s = (string)val;
                        break;

                    case BaseDataType.Int:
                        s = ((int)val).ToString();
                        break;

                    case BaseDataType.Float:
                        s = ((double)val).ToString("F");
                        break;

                    case BaseDataType.Currency:
                        s = ((decimal)val).ToString("N");
                        break;

                    case BaseDataType.DateTime:
                        s = ((DateTime)val).ToShortDateString();
                        break;

                    case BaseDataType.Bool:
                        s = ((bool)val) ? "Да" : "Нет";
                        break;

                    default:
                        s = val.ToString();
                        break;
                    }
                }
                cell.AddText(s, field.Style);
                colNo++;
            }
            else
            {
                var xlsCell = item as XlsCell;
                if (xlsCell != null)
                {
                    var cell = row.AddCell(colNo);
                    cell.Style   = xlsCell.Style;
                    cell.ColSpan = 1;
                    var val = xlsCell.GetValue();
                    cell.AddText(val != null ? val.ToString() : String.Empty, xlsCell.Style);
                    colNo++;
                }
                else
                {
                    var xlsNode = item as XlsNode;
                    if (xlsNode != null)
                    {
                        var cell = row.AddCell(colNo);
                        cell.Style   = xlsNode.Style;
                        cell.ColSpan = item.GetCols();
                        var textNode = item as XlsTextNode;
                        if (textNode != null)
                        {
                            cell.AddText(textNode.Text, xlsNode.Style);
                        }
                        else
                        {
                            var cellNode = item as XlsCellNode;
                            if (cellNode != null)
                            {
                                var val = cellNode.Cell.GetValue();
                                cell.AddText(val != null ? val.ToString() : String.Empty, xlsNode.Style);
                            }
                        }

                        var node = xlsNode;
                        if (node.Items.Count > 0)
                        {
                            AddNodeCell(node, table, rowNo + 1, colNo);
                        }
                        colNo += node.GetCols();
                    }
                }
            }
        }