Пример #1
0
        public OpenXmlWordCell(WordDocHolder docHolder, TableWidthInfo tableWidth, TableCell inputCell, int row, int column)
        {
            InitTextProperties(docHolder, inputCell);
            var vmerge = inputCell.TableCellProperties.GetFirstChild <VerticalMerge>();

            if (vmerge == null)
            {
                IsVerticallyMerged = false;
            }
            else
            {
                if (vmerge == null || vmerge.Val == null || vmerge.Val == MergedCellValues.Continue)
                {
                    IsVerticallyMerged = true;
                }
                else
                {
                    //vmerge.Val == MergedCellValues.Restart
                    IsVerticallyMerged = false;
                }
            }
            var gridSpan = inputCell.TableCellProperties.GetFirstChild <GridSpan>();

            IsMerged        = gridSpan != null && gridSpan.Val > 1;
            FirstMergedRow  = -1; // init afterwards
            MergedRowsCount = -1; // init afterwards

            MergedColsCount = (gridSpan == null) ? 1 : (int)gridSpan.Val;
            Row             = row;
            Col             = column;
            if (inputCell.TableCellProperties != null &&
                inputCell.TableCellProperties.TableCellWidth != null &&
                inputCell.TableCellProperties.TableCellWidth.Type != null &&
                inputCell.TableCellProperties.TableCellWidth.Type != TableWidthUnitValues.Auto
                )
            {
                CellWidth = TableWidthInfo.TryReadWidth(
                    inputCell.TableCellProperties.TableCellWidth.Width,
                    inputCell.TableCellProperties.TableCellWidth.Type,
                    tableWidth.TableWidthInPixels);
            }
            else
            {
                if (Col < tableWidth.ColumnWidths.Count)
                {
                    CellWidth = tableWidth.ColumnWidths[Col];
                }
            }
            AdditTableIndention = tableWidth.TableIndentionInPixels;
        }
Пример #2
0
        TableWidthInfo InitializeTableWidthInfo(WordDocHolder docHolder, Table table)
        {
            TableWidthInfo  widthInfo = new TableWidthInfo();
            TableProperties tProp     = table.GetFirstChild <TableProperties>();

            if (tProp != null)
            {
                if (tProp.TableWidth != null)
                {
                    widthInfo.TableWidthInPixels = TableWidthInfo.TryReadWidth(
                        tProp.TableWidth.Width,
                        tProp.TableWidth.Type,
                        docHolder.DocumentPageSizeInPixels);
                }

                if (tProp.TableIndentation != null)
                {
                    widthInfo.TableIndentionInPixels = TableWidthInfo.TryReadWidth(
                        tProp.TableIndentation.Width,
                        tProp.TableIndentation.Type,
                        docHolder.DocumentPageSizeInPixels);
                }
                widthInfo.TableIndentionInPixels += docHolder.DocumentPageLeftMaginInPixels;
            }
            else
            {
                widthInfo.TableWidthInPixels = docHolder.DocumentPageSizeInPixels;
            }
            TableGrid tGrid = table.GetFirstChild <TableGrid>();

            if (tGrid != null)
            {
                widthInfo.ColumnWidths = new List <int>();
                foreach (var col in tGrid.Elements <GridColumn>())
                {
                    widthInfo.ColumnWidths.Add(
                        TableWidthInfo.TryReadWidth(
                            col.Width,
                            TableWidthUnitValues.Dxa,
                            widthInfo.TableWidthInPixels));
                }
            }
            return(widthInfo);
        }