View | Details | Raw Unified | Return to bug 58191
Collapse All | Expand All

(-)a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTableRow.java (-1 / +39 lines)
Lines 82-85 public class XSLFTableRow implements Iterable<XSLFTableCell> { Link Here
82
    }
82
    }
83
83
84
84
85
    /**
86
     * Merge cells of a table row.
87
     * Indices are 0-based.
88
     *
89
     * @return true if cells were merged
90
     */
91
    public boolean mergeCells(int firstCol, int lastCol)
92
    {
93
        if (firstCol > lastCol)
94
        {
95
            throw new IllegalArgumentException
96
            (
97
                "Cannot merge, first column > last column : "
98
              + firstCol + " > " + lastCol
99
            );
100
        }
101
102
        int colSpan = (lastCol - firstCol) + 1;
103
        if (colSpan < 2)
104
        {
105
            return false;
106
        }
107
108
        for (int colI = firstCol; colI <= lastCol; ++colI)
109
        {
110
            XSLFTableCell cel = _cells.get(colI);
111
            if (colI == firstCol)
112
            {
113
                cel.setGridSpan(colSpan);
114
            }
115
            else
116
            {
117
                cel.setHMerge(true);
118
            }
119
        }
120
121
        return true;
122
    }
123
85
}
124
}
86
- 

Return to bug 58191