Bug 52658 - [PATCH] Merge cells of a table (rowspan and colspan)
Summary: [PATCH] Merge cells of a table (rowspan and colspan)
Alias: None
Product: POI
Classification: Unclassified
Component: XSLF (show other bugs)
Version: 3.8-dev
Hardware: PC Windows XP
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
Depends on:
Reported: 2012-02-13 23:22 UTC by Ut Vu Phan
Modified: 2012-02-14 07:03 UTC (History)
0 users

SVN Diff created by the "ant -f patch" command (4.66 KB, patch)
2012-02-13 23:24 UTC, Ut Vu Phan
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ut Vu Phan 2012-02-13 23:22:56 UTC
I was trying to merge table's cell in a Powerpoint document and found nothing in the API. Searching on the net, I only found out that it's was simply not implemented.


I made a quick patch in the XSLFTableCell class to expose the 'gridSpan', 'rowSpan', 'hMerge' and 'vMerge' attributes of the "tc" element (the table cell node in the OOXML schema) and added a method in the XSLFTable class to merge the desired cells :
  public void mergeCells(int firstRow, int lastRow, int firstCol, int lastCol);

In the client code :

   XSLFTable table = newSlide.createTable();
   XSLFTableRow row = table.addRow();
   table.mergeCells(0, 1, 0, 1);

Note : You need the full OOXML-schemas jar file (16 MB) to make the (Powerpoint) table work in POI.  The lite version don't seem to work for me.

Due to project rush I only implemented what I need and didn't review side effect s or alternative uses (exemple : merge all the cell in the table, unmerge cells, etc ?)
Comment 1 Ut Vu Phan 2012-02-13 23:24:15 UTC
Created attachment 28325 [details]
SVN Diff created by the "ant -f patch" command
Comment 2 Yegor Kozlov 2012-02-14 07:03:21 UTC
Patch applied in r1243793