All articles

PDF invoices to Excel: one checked table, not copy-paste

In short. To get PDF invoices into Excel, use a PDF import for suitable tables, OCR for scans, or a parser adapted to known layouts. Keep one row per invoice, the source reference and a review status. The teaching example below validates dates and selected amount formats without guessing ambiguous values. It does not extract PDFs, perform OCR or create an Excel workbook.

Drawn invoices with different layouts feed into one uniform table, with one row highlighted for review.
Illustrative data flow, not actual client records. Keep a trace from each row to its source document.

Moving PDF invoices to Excel sounds like a small job. You have a folder of PDFs. Each supplier uses its own layout, its own labels and its own way of writing dates and amounts. You need one table: invoice number, date, supplier, net, VAT, total. And you need to trust it.

Copying by hand is fine for five invoices. At fifty, mistakes creep in: a comma mistaken for a thousands separator, a date flipped, a total that never added up to begin with.

What are the ways to get PDF invoices into Excel?

Way Good for Watch out for
Excel’s PDF import (Data, Get Data, From File, From PDF) a few invoices with clean tables it finds tables, not meaning; each layout may need its own steps; nothing checks the totals
An online converter a one-off file where your invoices are sent and stored; the output still has to be checked
A small script many invoices, different suppliers, every month it has to be set up once for your layouts

Microsoft’s PDF connector returns the tables it finds in a PDF. It can merge similar tables on consecutive pages, and for several files at once Microsoft points to the Folder connector. It also notes that some capabilities exist in one product but not another, so check that your Excel version shows the option.

If you get a few invoices a month from one supplier, Excel is fine. Once you have several suppliers and it is a monthly task, a script is worth it: you set the rules once and rerun them.

What should the finished table look like?

One row per invoice; one row per PDF only when each file contains exactly one invoice. Use the same columns for every supplier, dates in one format (2026-09-03), amounts as plain numbers (1240.00), and one extra column: needs review.

That last column matters most. A good process does not guess. If an invoice has no number, or net plus VAT does not equal the total, the row stays as it is and is flagged. A person decides.

How does a script read invoices?

The example expects one labelled field per line, a colon after the label and a date order agreed for the supplier. Supported labels are English, French and German. It keeps the extracted text beside the result, checks calendar dates, accepts zero and signed amounts, and flags missing, repeated or ambiguous fields. It compares net plus VAT with the total only when all three values are available.

It is deliberately limited: multi-rate VAT, percentages beside the tax amount, discounts, rounding adjustments, other currencies and changing layouts need explicit rules. Arithmetic agreement does not prove that the invoice is valid or that the right fields were selected. The output is a Python dictionary, not an Excel file.

import re
from datetime import date
from decimal import Decimal

LABELS = {
    "number": r"(?:Invoice\s*No\.?|Facture\s*n°|Rechnungsnummer)",
    "date": r"(?:Date|Datum)",
    "net": r"(?:Subtotal|Total\s*HT|Nettobetrag)",
    "vat": r"(?:VAT|TVA|MwSt\.?)",
    "total": r"(?:Total\s*TTC|Total\s*due|Gesamtbetrag)",
}

def money(raw):
    # Only EUR-style amounts with at most two decimal places are in scope.
    value = re.sub(r"\s*(?:EUR|€)\s*$", "", raw.strip(), flags=re.I)
    value = value.replace("\u00a0", " ").replace("\u202f", " ")
    if not re.fullmatch(r"[+-]?\d[\d., ]*", value):
        raise ValueError("unsupported amount")
    sign = "-" if value.startswith("-") else ""
    value = value.lstrip("+-")
    separators = [c for c in ".," if c in value]
    decimal = None
    if len(separators) == 2:
        decimal = max(separators, key=value.rfind)
    elif separators:
        sep = separators[0]
        # 1,240 or 1.240 could mean 1240 or 1.240: never guess.
        if value.count(sep) != 1 or len(value.rsplit(sep, 1)[1]) not in (1, 2):
            raise ValueError("ambiguous amount")
        decimal = sep
    integer, fraction = value.rsplit(decimal, 1) if decimal else (value, "")
    if decimal and not re.fullmatch(r"\d{1,2}", fraction):
        raise ValueError("unsupported precision")
    grouping = [c for c in "., " if c in integer]
    if len(grouping) > 1:
        raise ValueError("mixed grouping")
    if grouping:
        sep = grouping[0]
        if sep == decimal or not re.fullmatch(r"\d{1,3}(?:" + re.escape(sep) + r"\d{3})+", integer):
            raise ValueError("invalid grouping")
        integer = integer.replace(sep, "")
    if not integer.isdigit():
        raise ValueError("invalid integer")
    return Decimal(sign + integer + ("." + fraction if fraction else ""))

def parse(text, day_first=True):
    row, raw_values, flags = {}, {}, []
    for key, label in LABELS.items():
        matches = re.findall(r"^[ \t]*" + label + r"[ \t]*:[ \t]*([^\r\n]*)$", text, re.I | re.M)
        raw_values[key] = matches
        row[key] = matches[0].strip() if len(matches) == 1 else None
        if row[key] is None or not row[key]:
            flags.append("missing or repeated " + key)
            row[key] = None
    if row["date"] is not None:
        try:
            if not re.fullmatch(r"\d{1,2}[./]\d{1,2}[./]\d{4}", row["date"]):
                raise ValueError("unsupported date")
            first, second, year = map(int, re.split(r"[./]", row["date"]))
            day, month = (first, second) if day_first else (second, first)
            row["date"] = date(year, month, day).isoformat()
        except ValueError:
            flags.append("invalid date")
            row["date"] = None
    for key in ("net", "vat", "total"):
        if row[key] is not None:
            try:
                row[key] = money(row[key])
            except ValueError:
                flags.append("invalid or ambiguous " + key)
                row[key] = None
    if all(row[key] is not None for key in ("net", "vat", "total")):
        if row["net"] + row["vat"] != row["total"]:
            flags.append("totals differ")
    row["raw_values"] = raw_values
    row["needs_review"] = "; ".join(flags)
    return row
Pencil illustration of a person comparing an invoice with a spreadsheet, beside separate checked and unresolved document trays.
Human review stays visible: an unresolved row is not silently corrected or presented as an approved accounting entry.

Which columns should you keep besides the amounts?

At least the supplier name, the currency and the name of the original PDF file. That last column costs a second to write and saves hours: when a row looks odd, you open exactly the right invoice. Also keep the extraction date, so you know which version of the rules produced which table.

What happened on a test set?

The published parser is tested against fictional text fixtures: standard invoices, zero VAT, signed credit amounts, mismatched totals, missing or repeated fields, invalid and leap-year dates, different date orders, and ambiguous amounts such as 1,240 or 1.240. The ambiguous values remain unresolved and retain their raw text.

These are isolated parser tests, not an OCR, real-PDF extraction or Excel-export test. A production workflow needs authorised sample documents, supplier-specific rules and end-to-end acceptance checks. A blank review status only means these limited checks found no issue.

Which traps break a PDF invoice table?

  • Decimal comma or point. 1.240,00 and 1,240.00 are the same amount; 1,240 can be either. Decide the rule for each supplier.
  • Day and month. 03/04/2026 is 3 April in France and, in US format, 4 March. Set the order before you run anything.
  • Several VAT rates on one invoice. One net and one VAT column are not enough; keep a line per rate or a total with a note. The French invoice rules ask for the VAT rate on each line, so a single VAT figure can hide mixed rates.
  • Credit notes. They should show as negative amounts, not as a second invoice that doubles your spending.
  • Currency. If a supplier uses another currency, keep a currency column and convert later, never silently.
  • Layout drift. Excel’s connector and any script read what is on the page. A supplier who moves the totals box can break a rule without any error message, which is another reason for the check below.

What is worth checking before you trust the table?

Five minutes, every time:

  1. Reconcile rows with the invoices in the agreed scope, not automatically with the number of PDF files: one file may contain several invoices or several pages of the same invoice.
  2. Compare extracted totals with the same source invoices and agreed scope. Reconcile payments separately: bank dates, partial payments and unpaid invoices do not necessarily match invoice totals for a month.
  3. Check suspected duplicates using supplier identity plus invoice number, with source references. Different suppliers can use the same number. Do not delete a row or infer a missing invoice from another supplier’s sequence.
  4. Open three random invoices and compare them with their rows.
  5. Every row in the review list gets a decision: fixed by hand, or confirmed as it is.

When is a script not enough?

  • Scans are pictures. pypdf’s documentation states it is not OCR software and “will never be able to extract text from images”, so scans need text recognition first, and the recognised digits need checking.
  • PDFs have no table structure. The same documentation explains that a PDF stores positioned text, not headers or tables, so reading layouts is always an approximation. That is why we flag instead of trusting.
  • New layouts need their labels added. It is usually quick, but someone has to do it.
  • Unusual number formats, like three digits after a comma, must be agreed on, not guessed.
  • Legal or accounting decisions stay with your accountant. A checked table helps them; it does not replace them.

Should you do it yourself or hand it over?

If you are comfortable with Python, the script above is enough to start. You can see the demo on made-up invoices on our work page. If you would rather send a folder and get back a checked table with a list of what needs your eye, that is our Documents into data service. If the files are confidential, the processing can stay on your computer or on ours in the EU: see private AI without the cloud.

What to do with an uncertain row

Keep raw values, source filename and page references beside the normalised fields. Record the reviewer and every correction. Never turn an unreadable amount into zero or infer a missing number.

The published example handles the listed date, zero-VAT, signed-amount and ambiguity cases, but it does not resolve supplier identity, mixed tax rates or arbitrary layouts. Use the review list and test real extraction and export separately before any accounting import. Agree transfer, access, storage and deletion; your accountant remains responsible for accounting decisions.

pypdf — text extraction.

Questions

Can scanned invoices be read the same way?

Not directly. A scan is a picture of paper, so the text has to be recognised first (OCR); pypdf's own documentation says it cannot extract text from images. After OCR the same rules apply, but every recognised number deserves a check.

What happens when an invoice has no number or the totals don't add up?

It should not be fixed silently. The row stays as printed and is flagged in a needs-review column for a person to decide.

Do the invoices leave my computer?

Only a verified fully local workflow avoids external processing. Check OCR, connected services, synchronised folders, logs, backups and support access before sending private files. A script alone does not guarantee confidentiality.

Can Excel combine many PDF invoices at once?

Microsoft's documentation says to use a multi-file connector such as the Folder connector to import several PDFs. Excel reads tables, though, so you still need to check each layout and the totals yourself.

Contact

One person reads this inbox — the same person who builds what you order.

Describe your task

Tell us what you have and what result you need — even a single small task. No brief required: within 48 hours you get a plan and a price in writing, a question, or an honest “not a fit”.

Include the situation, files or links, deadline, language, privacy limits and budget boundary if you have one.

File (optional)
No file chosen

A brief, a photo, a spreadsheet — whatever explains the task faster than words. Up to 8 MB, stored with our hosting provider. Please don't send sensitive personal or medical documents through the site.

Sending creates no order and no payment. We reply within 48 hours. Prefer email? contact@castel.studio

Talk to us

Prefer a call or a messenger? Write or call — the studio's founder answers.

Connect on LinkedIn

Prefer a freelance platform?

Order the same work there, with the platform's secure payment.

A one-person AI studio in Nice. Whoever answers your message is the one who does the work — no account managers in between. Files are processed on our own machine, not in someone else's cloud.

Nice 06100, France · Open in maps →

SIREN 103 115 705