示例#1
0
        public void MergeCells(int startIndex, int endIndex)
        {
            if (startIndex >= endIndex)
            {
                throw new ArgumentOutOfRangeException("Start index must be smaller than end index");
            }
            if (startIndex < 0 || endIndex >= this.tableCells.Count)
            {
                throw new ArgumentOutOfRangeException("Invalid start index and end index");
            }
            XWPFTableCell startCell = this.GetCell(startIndex);

            //remove merged cells
            for (int i = endIndex; i > startIndex; i--)
            {
                this.RemoveCell(i);
            }

            if (!startCell.GetCTTc().IsSetTcPr())
            {
                startCell.GetCTTc().AddNewTcPr();
            }
            CT_TcPr tcPr = startCell.GetCTTc().tcPr;

            if (tcPr.gridSpan == null)
            {
                tcPr.AddNewGridspan();
            }
            CT_DecimalNumber gridspan = tcPr.gridSpan;

            gridspan.val = (endIndex - startIndex + 1).ToString();
        }
示例#2
0
        public void Test54099()
        {
            XWPFDocument  doc     = new XWPFDocument();
            CT_Tbl        ctTable = new CT_Tbl();
            XWPFTable     table   = new XWPFTable(ctTable, doc);
            XWPFTableRow  tr      = table.GetRow(0);
            XWPFTableCell cell    = tr.GetCell(0);

            CT_Tc     ctTc   = cell.GetCTTc();
            CT_TcPr   tcPr   = ctTc.AddNewTcPr();
            CT_HMerge hMerge = tcPr.AddNewHMerge();

            hMerge.val = (ST_Merge.restart);

            CT_TcBorders tblBorders = tcPr.AddNewTcBorders();
            CT_VMerge    vMerge     = tcPr.AddNewVMerge();
        }