Trond Hansen wrote: > I’m trying to extract a MS-Word table with merged cells. If the cells > are vertically merged the TableRow.getCell(x).isVerticallyMerged() > method return true, but if cells are merged horizontally the TableRow > getCell(0).isMerged() return false. > > How do I get info about cell merging?
Hi, I took a quick look at some of my test files (Word 2000) and it looks like simple horizontally merged cells are not marked as such in Word files - the flags are just not set in the "raw records" and therefore the isMerged() method returns false. The flags for vertically merged cells are correctly set in the raw records, so the behaviour which you saw, represents what is stored in the Word file. Imagine this table: [________][___] [___][___][___] (if the drawing wraps: Three cols, two rows, first two cells merged) The first row consists of only two cells in the Word file. The width of the first cell is defined to cover two columns, but the cell is not flagged as "merged". So if you need to find out whether cells are merged or not, it may be necessary to compare number of cells and their widths between several rows. My first try: Determine max number of cells, see if any row contains less than the max, see which cell has another width than the corresponding cell of the row with the maximum number of cells. However, I remember that cell widths sometimes vary slightly so you may need to add a kind of threshold - something like "same width if it varies by not more than 0.1mm" or so. Note that this approach probably fails for situations like that: [________][___] [___][________] (last two cells merged too) That would require a more sophisticated cell width analysis... Should you need hints, just ask. Best wishes, Rainer -- --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
