TemplNET.TemplDoc.CellCopyProperties C# (CSharp) 메소드

CellCopyProperties() 공개 정적인 메소드

public static CellCopyProperties ( Cell fromCell, Cell toCell ) : void
fromCell Novacode.Cell
toCell Novacode.Cell
리턴 void
        public static void CellCopyProperties (Cell fromCell, Cell toCell)
        {
            if (!fromCell.FillColor.IsEmpty)
            {
                toCell.FillColor = fromCell.FillColor;
            }
            if (!fromCell.Shading.IsEmpty)
            {
                toCell.Shading = fromCell.Shading;
            }
            toCell.MarginBottom = fromCell.MarginBottom;
            toCell.MarginLeft = fromCell.MarginLeft;
            toCell.MarginRight = fromCell.MarginRight;
            toCell.MarginTop = fromCell.MarginTop;
            toCell.TextDirection = fromCell.TextDirection;
            toCell.VerticalAlignment = fromCell.VerticalAlignment;
        }

Usage Example

예제 #1
0
        public override TemplMatchTable Handler(DocX doc, object model, TemplMatchTable m)
        {
            m.Validate();
            var e        = TemplModelEntry.Get(model, m.Fields.First());
            var maxCells = TemplConst.MaxMatchesPerScope;

            if (m.Fields.Length == 2)
            {
                if (!uint.TryParse(m.Fields[1], out maxCells))
                {
                    throw new ArgumentException($"Templ: Dynamic Cell Module '{m.Placeholder}' has invalid maximum cells: '{m.Fields[1]}'");
                }
            }
            var keys       = e.ToStringKeys().Take((int)maxCells).ToList();
            var columnDiff = keys.Count() - m.Table.ColumnCount + m.CellIndex;

            for (int i = 0; i < columnDiff; i++)
            {
                m.Table.InsertColumn();
            }
            for (int i = 0; i < keys.Count(); i++)
            {
                var s = $"{TemplConst.MatchOpen}{TemplConst.Prefix.Text}{TemplConst.FieldSep}{m.Fields[0]}[{keys[i]}]{TemplConst.MatchClose}";
                var p = m.Row.Cells[i + m.CellIndex].Paragraphs.Last();
                p.InsertParagraphAfterSelf(m.Paragraph).ReplaceText(m.Paragraph.Text, s);
                p.Remove(trackChanges: false);
                TemplDoc.CellCopyProperties(m.Cell, m.Row.Cells[i + m.CellIndex]);
            }
            m.RemovePlaceholder();
            m.Removed = true;
            return(m);
        }