Extracting PDF Tables to Excel: The Deep Learning Approach
Say goodbye to merged columns, broken rows, and hours of manual transcription. Learn how IBM's TableFormer deep learning model extracts clean, calculation-ready spreadsheets from any PDF.
Automate Table Extraction in 3 Lines of Python
Docling uses TableFormer to predict cell spans and coordinates geometrically. Export directly to pandas DataFrames and Excel spreadsheets.
Borderless tables
Over 90% of tables in corporate earnings reports, SEC 10-K filings, and bank statements do not use solid gridlines. Instead, they use white space and typography to indicate column structure.
Traditional OCR tools look for black pixels separating columns. When lines are absent, they treat adjacent numbers as a single block of text. The result? A 10-column financial statement collapses into a chaotic single column in Excel.
How IBM TableFormer Solves It
TableFormer is an attention-based neural network trained specifically on millions of complex table structures. Rather than relying on ruling lines:
- Cell Bounding Box Prediction: Identifies individual content tokens and predicts which tokens form a single cell.
- Topological Matrix: Computes row-span and column-span relationships across multi-level headers.
- Coordinate Normalization: Maps numbers to their precise column alignment regardless of whitespace variance.
Python Implementation (3 Steps)
Install Docling with Excel Support
Install Docling, pandas, and openpyxl: pip install docling pandas openpyxl
Convert PDF with DocumentConverter
Pass your PDF to DocumentConverter().convert("file.pdf"). TableFormer automatically detects and reconstructs all tables.
Export Tables to pandas & Excel
Iterate through result.document.tables, call table.export_to_dataframe(), and save directly to XLSX or TSV.
TableFormer provides table cells and spans. For a table that continues across pages, check the repeated headings and totals against the source before joining the grids.
Related Docling guides
- Docling to Excel guide
Dataframe export and validation
- Why formatting breaks
Coordinate geometry vs gridlines
- OCR table extraction
Cell recognition and alignment
- PDF to Excel recipe
Edge case handling
- Tables that come out wrong
Four failures and their signatures
- Checking the output
Counting, reading and provenance