Tables with merged cells, read correctly. When a merged cell is misread, values shift into the wrong column and a figure lands under the wrong quarter. Parsers that work from a PDF have to guess merges from the rendered page. AILANG Parse reads the merge information stored in the Word, Excel or PowerPoint file, so every value stays in its own row and column.
The Problem
Tables are among the hardest parts of a document to parse. Cells hold lists and other content, columns vary in width, and headers span several rows. The hardest case is merged cells: one cell that spans two columns, three rows, or both. Get the merge wrong and the data shifts. A revenue figure lands under the wrong quarter, or a compliance field is matched to the wrong entity.
Parsers that convert to PDF first guess where the table borders are from the rendered page, and that fails on complex merges. A cell spanning columns 2–4 can look like three separate cells. A cell merged down five rows has no visible border to detect.
AILANG Parse reads the merge information from the Office file itself. The structure is already recorded there, in the gridSpan, vMerge and mergeCells elements, so nothing has to be guessed.
DOCX Tables
DOCX files follow the Office Open XML standard (OOXML, ECMA-376). A table is defined on a grid: the <w:tblGrid> element lists the columns, and each cell says how much of that grid it covers.
Horizontal Merges (gridSpan)
A cell that spans several columns carries a <w:gridSpan w:val="3"/> element. AILANG Parse reads it and returns it as the cell's colspan. Nothing is guessed from the width of the cell on the page.
<!-- OOXML: cell spanning 3 columns -->
<w:tc>
<w:tcPr>
<w:gridSpan w:val="3"/>
</w:tcPr>
<w:p><w:r><w:t>Total Revenue</w:t></w:r></w:p>
</w:tc>
Vertical Merges (vMerge)
A vertical merge is marked in two parts. The first cell has <w:vMerge w:val="restart"/>. The cells below it in the same column carry <w:vMerge/> with no val attribute, which means "continue". AILANG Parse follows the merge down the rows and works out the rowspan.
<!-- Row 1: start of vertical merge -->
<w:tc>
<w:tcPr><w:vMerge w:val="restart"/></w:tcPr>
<w:p><w:r><w:t>Category A</w:t></w:r></w:p>
</w:tc>
<!-- Row 2: continuation (empty vMerge = continue) -->
<w:tc>
<w:tcPr><w:vMerge/></w:tcPr>
<w:p/>
</w:tc>
<!-- Row 3: continuation -->
<w:tc>
<w:tcPr><w:vMerge/></w:tcPr>
<w:p/>
</w:tc>
The result is one cell with rowspan: 3. The continuation cells are left out, because they hold no content.
Combined Merges
A cell can have both gridSpan and vMerge, which makes a block that spans several rows and several columns. AILANG Parse reads both from the cell's <w:tcPr> element and returns both spans.
XLSX Tables
Excel records merges in a <mergeCells> element in each sheet. Each merge is a range such as B2:D4: columns B to D and rows 2 to 4 are one cell.
<!-- XLSX: sheet1.xml merge declarations -->
<mergeCells count="2">
<mergeCell ref="B2:D4"/>
<mergeCell ref="A1:C1"/>
</mergeCells>
AILANG Parse reads these ranges and applies them to the cell data. In the resulting table, each merged range is a single cell with its colspan and rowspan.
Shared Strings
XLSX files keep text values in one shared list (sharedStrings.xml), and each cell refers to its text by number. AILANG Parse looks the text up, so the output contains the actual text, not the numbers.
PPTX Tables
PowerPoint tables use different element names from Word: the a: prefix (DrawingML) in place of w:. The columns are listed in <a:tblGrid> with <a:gridCol> elements, and a horizontal merge is a gridSpan attribute on the <a:tc> cell.
<!-- PPTX: table cell spanning 2 columns -->
<a:tc gridSpan="2">
<a:txBody>
<a:p><a:r><a:t>Merged Header</a:t></a:r></a:p>
</a:txBody>
</a:tc>
A vertical merge in PPTX is a rowSpan attribute on the first cell and vMerge="1" on the cells below it. AILANG Parse reads both.
Example Output
For a DOCX table where "Total Revenue" spans columns 2–4 and "Category A" spans rows 1–3, AILANG Parse returns:
{
"type": "Table",
"rows": [
{
"cells": [
{ "text": "Category A", "rowspan": 3 },
{ "text": "Total Revenue", "colspan": 3 }
]
},
{
"cells": [
{ "text": "Q1", "colspan": 1 },
{ "text": "Q2", "colspan": 1 },
{ "text": "Q3", "colspan": 1 }
]
},
{
"cells": [
{ "text": "$1.2M", "colspan": 1 },
{ "text": "$1.5M", "colspan": 1 },
{ "text": "$1.8M", "colspan": 1 }
]
}
]
}
The rowspan: 3 on "Category A" comes from the three vMerge elements in a row in the file. The colspan: 3 on "Total Revenue" comes from gridSpan="3". No AI and no layout detection is involved.
Table block. You get the same shape whether the source is DOCX, XLSX or PPTX, with colspan and rowspan on each cell.How Other Parsers Handle This
OfficeDocBench checks tables against the source file: is each value in the right cell, are the merges right, are formulas kept. Scores for five parsers:
| Parser | Table cells: position, merges, formulas |
|---|---|
| AILANG Parse | 100.0% |
| Unstructured | 78.8% |
| Docling | 93.0% |
| LlamaParse | 76.4% |
| MarkItDown | 81.0% |
Read from the published OfficeDocBench results, on the files each parser could read.
Why PDF Conversion Loses Merge Information
When a DOCX is converted to PDF, the table becomes lines and text on a page. The gridSpan and vMerge values are used to draw it and are not written to the PDF. The PDF shows how the table looks, with no record of which cells were merged.
A tool that works from the PDF has to rebuild the table from the positions of lines and text. That works for simple tables with visible borders. It fails when:
- Cells are merged across columns. The border between them is gone, so the tool sees one wide cell and cannot tell how many columns it spans.
- Cells are merged vertically. With no horizontal border, the rows run together.
- The table has no visible borders at all, which is common in financial statements.
- Tables are nested, or cells contain lists or images.
AILANG Parse does not convert to PDF, so none of this applies. It reads the merge information from the Office file.
Try It
Parse a document with tables and look at the output:
# Parse a DOCX with merged cells
docparse report.docx
# Parse an XLSX spreadsheet
docparse budget.xlsx
# Parse a PPTX with tables
docparse deck.pptx
# Convert a table-heavy DOCX to HTML (preserves colspan/rowspan)
docparse report.docx --convert output.html
AILANG Parse is also available as part of Sunholo Multivac, our AI platform for enterprise document processing, with dedicated support for financial and compliance workflows.
Contact Sunholo →
Frequently Asked Questions
How do I parse DOCX tables and preserve merged cells?
AILANG Parse reads w:gridSpan (horizontal merge) and w:vMerge (vertical merge) from the DOCX. Each cell in the output has a colspan and rowspan, taken from the file and not guessed from the page layout.
Why do most document parsers break table structures from DOCX files?
Many parsers convert the DOCX to PDF first, which turns a table into text placed on a page. A model then tries to rebuild the grid from the positions. Merged cells, nested tables and cells with several paragraphs make that ambiguous. AILANG Parse reads the table from the DOCX, where the grid is stored.
How does AILANG Parse handle complex tables with nested content?
A table cell can contain any kind of content: paragraphs, lists, nested tables or images. AILANG Parse reads everything inside the cell and keeps its structure. Cells are not flattened to a single paragraph.
How does AILANG Parse compare to other parsers for DOCX table extraction?
On OfficeDocBench, AILANG Parse scores 95.0% and reads every file. The scores for the other parsers are on the benchmarks page. Converting to PDF discards the merge information that AILANG Parse reads from the file.
Format Guides
AILANG Parse reads tables from DOCX, XLSX, PPTX and HTML files. The format guides list everything else it extracts:
DOCX Parsing → · XLSX Parsing → · PPTX Parsing → · HTML Parsing →