コード例 #1
0
        public void Process(ShapeElementBase shape)
        {
            element = shape as TableElement;
            if (element.Data == null)
            {
                return;
            }
            element.Data = element.Data.GetFragmentByIndexes(element.RowIndexes, element.ColumnIndexes);
            element.ProcessCommands(element.Data);

            A.GraphicData graphicData = element.TableFrame.Graphic.GraphicData;
            Table         table       = graphicData.FirstElement <Table>();

            if (table == null)
            {
                return;
            }

            int rowsInTable    = table.Elements <TableRow>().Count();
            int columnsInTable = table.Elements <TableRow>().First().Elements <TableCell>().Count();

            if (element.UseColumnHeaders)
            {
                rowsInTable--;
            }
            if (element.UseRowHeaders)
            {
                columnsInTable--;
            }
            if (element.IsFixed)
            {
                element.Data.TrimOrExpand(columnsInTable, rowsInTable, false);
            }
            else
            {
                PrepareTable(table, element.UseRowHeaders, element.UseColumnHeaders);
            }

            int startFromRow = 0;

            if (element.UseColumnHeaders)
            {
                TableRow      tableRow = table.Elements <TableRow>().First();
                List <object> rowData  = element.Data.Columns.Select(c => (object)c.GetHeader()).ToList();
                FillRowWithHeaders(tableRow);
            }

            for (int rowIndex = 0; rowIndex < element.Data.Rows.Count; rowIndex++)
            {
                int      tableRowIndex = element.UseColumnHeaders ? rowIndex + 1 : rowIndex;
                TableRow tableRow      = table.Elements <TableRow>().ElementAt(tableRowIndex);
                Row      row           = element.Data.Rows[rowIndex];

                FillRowWithData(tableRow, row);
                SetCellStyleFromLegend(tableRow, row);
            }
        }