Scanned PDF to Excel, with numbers that add up
0 of 263
numbers Excel could add, from 3 free tools
Docling read 99.5% of cells
| Way | Rough scans | Clean scans |
|---|---|---|
| Docling | 99.5% | 99.0% |
| Our Actor's code (paid) | 99.3% | 99.7% |
| camelot, ml flavor | 80.5% | 89.7% |
| OCRmyPDF, camelot stream | 74.3% | 85.4% |
| OCRmyPDF, camelot lattice | 46.2% | 53.5% |
| img2table, borderless | 39.9% | 40.1% |
| img2table, defaults | 2.0% | 2.2% |
Ten made-up tables: bank statements, invoices, payroll and a trial balance. 6 have grid lines. Each became two simulated scans: rough, with blur and noise, and clean, like a good office scanner.
Every tool wrote numbers as text
A cell can hold 1,250.00 as a number, or as text that looks like one. SUM skips text.
On Docling's trial balance, =SUM(C2:C13) gave 0 in
LibreOffice. After fix_numbers.py it gave 119,494.51, the true total.
| Way | As written | After the fix | Column totals right |
|---|---|---|---|
| Docling | 0 | 263 | 27 of 27 |
| Our Actor's code | Markdown | 261 | 25 of 27 |
| camelot, ml flavor | 0 | 238 | 15 of 27 |
| camelot stream | 0 | 209 | 12 of 27 |
| camelot lattice | 0 | 137 | 7 of 27 |
| img2table, borderless | 0 | 101 | 9 of 27 |
Fix them with fix_numbers.py
pip install openpyxl
python fix_numbers.py tables.xlsx
It writes tables-fixed.xlsx. It also reads a .csv file, or Markdown tables like our Actor's. It reads US style numbers only, like 1,234.56.
| Text in the cell | Becomes |
|---|---|
| 1,234.56 or $1,234.56 | a number |
| (64.18) or 86.14- | a negative number |
| 12.5% | 0.125, shown as a percent |
| 03/14/2026 or 2026-03-14 | a date (add --day-first for 14/03/2026) |
| 00712, 02134 | stays text, with the rest of its column |
It prints each cell that stayed text in a column of numbers. On
Docling's and our Actor's 40 files it printed two cells, and both were
OCR misreads, like 1,204 ,330.50.
Docling: the best free way
pip install docling
import sys
from docling.document_converter import DocumentConverter
import pandas as pd
doc = DocumentConverter().convert(sys.argv[1]).document
if not doc.tables:
sys.exit("no table found")
with pd.ExcelWriter(sys.argv[2]) as xw:
for i, table in enumerate(doc.tables, 1):
df = table.export_to_dataframe(doc=doc)
df.to_excel(xw, sheet_name=f"Table {i}", index=False)
python scan2xlsx.py scan.pdf tables.xlsx
python fix_numbers.py tables.xlsx
- Save the middle block as scan2xlsx.py. Docling's own command has no Excel output.
- It took 8.3 seconds a page here, with 2 threads on a busy Mac. The first run downloads its models.
-
Its misreads: "lb" as "Ib",
($45.00)as(S45.00), and the code 05000 as 050.
camelot: OCRmyPDF first, or the ml flavor
ocrmypdf -l eng scan.pdf ocr.pdf
camelot stream -p all -o tables.xlsx ocr.pdf
-
lattice and stream read a text layer, so OCRmyPDF adds one. Use
latticefor grid lines,streamfor none. -
Its .xlsx adds a row and a column of index numbers (0, 1, 2). In
Python,
table.to_excel()leaves them out. - When it finds no table, it still writes an .xlsx with one empty sheet, and no error.
The ml flavor reads the scan itself, in Python only:
pip install "camelot-py[ml,ocr]" "transformers<5"
import camelot
tables = camelot.read_pdf("scan.pdf", flavor="ml", pages="all")
tables.export("tables.xlsx", f="excel")
With transformers 5.24.1, every page failed with a ValueError, hence the pin. It took about 6 seconds a page.
img2table found no grid on our scans
With its defaults, img2table read almost nothing. With
borderless_tables=True and
implicit_rows=True it read the tables without lines at
98.2%, but still missed the grids.
It found both grids on the original digital page at 200 dpi, the dpi its PDF reader uses, but not on any scan. On other scans it did better: see table image to CSV.
No OCR install: our Actor
PDF OCR to Markdown, our Apify Actor, reads a scanned PDF by URL and returns its tables
as Markdown. Save that as tables.md, then run
python fix_numbers.py tables.md.
- One number misread that fix_numbers.py cannot flag: a stock change of -6 came out as 6. Compare the totals with the page.
- A scanned page costs $0.006, plus $0.00005 to start each run, with an Apify token. The call is on PDF OCR API.
What I did not test
- Excel's own PDF and picture import, and Adobe Acrobat. Neither is on this Mac.
- Online converters. I upload no files.
- Tables over two pages, handwriting, and the 1.234,56 number style.
How I tested it
- 10 made-up tables, 591 cells, with 263 numbers and 32 full dates.
- 4 tables hold the cells of the scans on PDF to CSV.
- The scans are drawn by code at 300 dpi. Rough: heavy blur, noise and JPEG. Clean: light blur and noise.
- A cell is right when it shows the true text, number or date. Runs of spaces count as one.
- Docling 2.143.1 with RapidOCR, and camelot-py 2.2.0.
- OCRmyPDF 17.13.0, img2table 2.0.0 and Tesseract 5.5.4.
- openpyxl read every file, and LibreOffice ran the SUM, on macOS.
- Our Actor's code is build 0.1.141, run on our Mac.
- Scripts and results stay in our private repo, in research/bench/scanned-pdf-to-excel-2026-11-25/.
Sources
Questions people ask
How do I convert a scanned PDF to Excel for free?
Run Docling with the 11-line script on this page, then fix_numbers.py. On our rough scans, Docling got 99.5% of the cells right, and the fix made every number one Excel can add.
Why does SUM give 0 on my converted table?
The numbers came in as text, and SUM skips text. Every free tool we tested did this. Run fix_numbers.py on the .xlsx file to turn them into real numbers.
Does it keep the leading zeros in codes and ZIP codes?
Yes. A code with a leading zero, like 02134, stays text, and so does the rest of its column. Docling and our Actor kept all 39 such codes on the rough scans.
Related guides
- Convert PDF to CSV for free: 12 ways tested on 156 tables
- Photo to Excel: free table OCR tested on 12 phone photos
- Bank statement PDF to Excel
- Table image to CSV in Python: img2table vs Tesseract, tested
- How to make a PDF searchable: scanned PDFs, tested
- Docling OCR engines: EasyOCR vs Tesseract vs RapidOCR