How to Handle Merged Cells When Exporting Web Tables (rowspan/colspan Guide)
Government reports, financial statements, school timetables — the most useful data tables on the web are also the most complex. They use merged cells to group categories, span headers across columns, or create multi-level layouts. And when you try to copy them to Excel, everything falls apart.
This guide explains why merged cells break, what rowspan and colspan actually are, and how to export them correctly with zero manual cleanup.
What Are rowspan and colspan?
In HTML, tables are built with <tr> (rows), <td> (data cells), and <th> (header cells). Two attributes control cell merging:
rowspan="3"— this cell spans 3 rows vertically;colspan="2"— this cell spans 2 columns horizontally.
Here's a typical example from a government budget table:
<tr><th rowspan="2">Department</th><th colspan="2">Budget (USD)</th></tr>
<tr><th>2025</th><th>2026</th></tr>
<tr><td>Education</td><td>1,200,000</td><td>1,350,000</td></tr>
</table>
The header "Department" spans 2 rows; "Budget (USD)" spans 2 columns. This creates a clean hierarchy — but it's exactly what breaks on copy-paste.
Why Merged Cells Break on Copy-Paste
When you select this table in a browser and Ctrl+C, the browser sends raw HTML to the clipboard. Excel receives it and tries to map HTML cells to spreadsheet cells. The problem:
- rowspan cells — Excel may only paste the value in the first row, leaving the next row's first cell empty. Your "Education" label disappears from the second data row;
- colspan cells — Excel may push the merged header into one cell but leave the adjacent cells blank, shifting all subsequent columns to the right;
- Multi-level headers — tables with 2-3 header rows using both rowspan and colspan produce completely garbled output;
- Nested tables — some sites put tables inside table cells. Copy-paste treats them as one flat table, destroying the structure.
Result: 30 minutes of manual cleanup for a table that took 2 seconds to display.
The Fix: Read the HTML Structure, Not the Rendered Copy
The fundamental problem is that copy-paste operates on the rendered output. To get merged cells right, you need a tool that reads the underlying HTML attributes — the actual rowspan and colspan values — and reconstructs the grid mathematically before exporting.
That's exactly what VKT TableGrab does:
- It scans the page for all
<table>elements; - For each cell, it reads
rowspanandcolspanattributes; - It builds a 2D grid, filling merged values across all spanned cells;
- It exports the grid as a properly structured CSV.
The result: "Education" appears in every row it should, "Budget (USD)" spans correctly as a header, and all columns align.
How to Use TableGrab for Merged-Cell Tables
- Install from the Chrome Web Store or Edge Add-ons;
- Open the page with the complex table;
- Click the TableGrab icon — it auto-detects all tables;
- Hover over a table in the list to highlight it on the page;
- Click Export — the CSV downloads with merged cells properly reconstructed.
No DevTools, no scripts, no manual fixing. The free tier handles up to 5 tables per page — more than enough for most reports.
Note on CSV format: CSV is a plain-text format — it doesn't support visual cell merging. TableGrab solves this by repeating the merged value in every spanned cell. When you open the CSV in Excel, the data is complete and correct. If you need visual merging, apply it in Excel after import (Data → Consolidate or conditional formatting).
FAQ
What are rowspan and colspan in HTML tables?
They are HTML attributes that merge cells across rows and columns. A cell with rowspan="3" spans three rows; colspan="2" spans two columns. They're used for headers, grouped data, and visual hierarchy.
Why do merged cells disappear when I copy a table to Excel?
The browser sends HTML to Excel, which doesn't always reconstruct rowspan/colspan correctly. It may leave blank cells, shift columns, or lose the merge entirely. VKT TableGrab reads the HTML attributes directly and rebuilds the grid before exporting.
How do I export an HTML table with merged cells to CSV?
Use VKT TableGrab. It parses rowspan and colspan, fills merged values across all spanned cells, and exports a properly structured CSV. No manual fixing needed.
Does CSV support merged cells?
No — CSV is plain text with no merge concept. TableGrab repeats the merged value in every spanned cell so the data is preserved. Apply visual merging in Excel after import if needed.
More guides in the VKT blog; questions to [email protected].
