Exemplo n.º 1
0
        protected override void Write(PPTXRenderer renderer, Table table)
        {
            var tableObj = new PPTXTable();

            foreach (var tableColumnDefinition in table.ColumnDefinitions)
            {
                var pptxTableColObj = new PPTXTableColumn();

                var alignment = tableColumnDefinition.Alignment;
                if (alignment.HasValue)
                {
                    switch (alignment)
                    {
                    case TableColumnAlign.Center:
                        pptxTableColObj.Alignment = PPTXTableColumnAlign.Center;
                        break;

                    case TableColumnAlign.Right:
                        pptxTableColObj.Alignment = PPTXTableColumnAlign.Right;
                        break;

                    case TableColumnAlign.Left:
                        pptxTableColObj.Alignment = PPTXTableColumnAlign.Left;
                        break;
                    }

                    tableObj.Columns.Add(pptxTableColObj);
                }
            }

            renderer.PushBlockSetting(renderer.Options.Table);
            renderer.AddTable(tableObj);

            foreach (var rowObj in table)
            {
                renderer.AddTableRow();

                var row = (TableRow)rowObj;

                for (int i = 0; i < row.Count; i++)
                {
                    renderer.NextTableCell();

                    renderer.WriteChildren((TableCell)row[i]);
                }

                renderer.EndTableRow();
            }

            renderer.PopBlockSetting();
            renderer.AddTableEnd();
        }