PDF to Excel: pull tables out of a PDF and clean them up
Bank statements, price lists and invoice summaries arrive as PDFs, but the math happens in Excel. No need to retype anything: Power Query reads tables straight from the PDF and shapes them into numbers you can work with.
In short: Data > Get Data > From File > From PDF, pick the file, select the table in the Navigator and click Load or Transform Data. According to Microsoft's overview, the PDF connector is part of the Microsoft 365 plans on Windows, not Office 2016 or 2019, and not Excel for Mac.
Try it now
A two-page invoice list from a PDF has landed in the Power Query Editor. As so often, the headers are missing, the header row from page 2 sits in the middle of the data, and the amounts are text. Clean up the query.
Task The invoice list comes from a two-page PDF. Power Query did not detect the headers (Column1 to Column3), the header row from page 2 sits in the middle of the data, and Amount is text. Turn the first row into headers, remove the repeated header row and change the data type of Amount to Whole Number.
| A | B | C | |
|---|---|---|---|
| 1 | Invoice | Customer | Amount |
| 2 | INV-2041 | Hughes Ltd | 1240 |
| 3 | INV-2042 | Clark & Sons | 860 |
| 4 | INV-2043 | Patel Trading | 2315 |
| 5 | Invoice | Customer | Amount |
| 6 | INV-2044 | Brooks Supplies | 495 |
| 7 | INV-2045 | Evans Media | 1780 |
| 8 | INV-2046 | Turner Logistics | 930 |
How to load a PDF table into Excel
- Select Data > Get Data > From File > From PDF.
- Pick the PDF file and click Open. The Navigator opens and lists the tables Power Query found in the PDF.
- Select the table you need. You can select more than one.
- Decide what happens next:
- Load puts the table straight onto a new sheet. Load To opens the Import dialog so you choose where it goes.
- Transform Data opens the Power Query Editor first. That is almost always the better choice, because PDF tables usually need some tidying.
If a message says the connector needs additional components, the computer is missing .NET Framework 4.5 or later. Microsoft lists that as a requirement for the PDF connector.
Tables that span several pages
Long lists run across several pages in a PDF. The function behind the connector is Pdf.Tables, and Microsoft says it combines similar tables on consecutive pages into a single table by default. The option is called MultiPageTables. That is why the Navigator often shows one continuous table rather than one per page.
For very large PDFs, Microsoft suggests reading only a range of pages. In the editor's formula bar you can do that with the StartPage and EndPage options, for example:
Pdf.Tables(File.Contents("C:\Reports\List.pdf"), [StartPage=2, EndPage=5])
For a list of a few pages you will not need this.
Clean up the table
What comes out of a PDF is rarely ready to calculate with. These are the steps you will need most, all in the Power Query Editor:
| Problem | Step in the editor |
|---|---|
| Headers are called Column1, Column2 | Use First Row as Headers |
| Each page's header row sits in the data | Filter Rows: column does not equal its own header |
| Footers like "Page 1 of 3" or subtotals | Filter Rows, for example with "begins with" or "contains" |
| Amounts are text and sums come out as 0 | Data Type set to Decimal Number or Whole Number |
| Spaces at the start or end | Format: Trim |
| Empty columns | Select the column, Remove Columns |
Order matters: headers first, then remove the stray rows, and change data types last. Otherwise an old header row turns into an error, because "Amount" is not a number. Filtering, trimming and types are covered in detail in Power Query data cleaning.
After changing the type, check a few amounts against the PDF, especially numbers with thousands separators such as 1,240.50. A misread amount otherwise only shows up in the total.
Next month, just refresh
Power Query stores every click in the editor as a step of the query. When next month's PDF arrives with the same layout, save it under the same name in the same place and select Data > Refresh All. Power Query repeats every step, including removing the header rows, no matter how many pages the new file has.
Without Power Query: copy and Text to Columns
According to Microsoft, Excel for Mac and Office 2016 or 2019 do not have the PDF connector. That leaves the clipboard: select the table in your PDF reader, copy it and paste it into Excel. Depending on the reader, a whole row may end up in a single cell. Select that column and split it with Data > Text to Columns. That is fine for a short one-off list. For files that come back every month, Power Query saves a lot of time. Working with the table afterwards is covered in how to edit a table.
If the data also exists as a CSV or text file, use that instead: it reads in more reliably than any PDF. See import CSV.
Common mistakes
Clicking Load straight away
Then header and footer rows end up inside the table. No harm done: click in the result table and choose Edit on the Query tab to get back into the editor.
Changing the data type before filtering
Convert Amount to numbers while the repeated header row is still there, and that row shows an error. Remove the row first, then change the type.
Renaming or moving the file
The query remembers the path to the PDF. If the new file lives somewhere else, update the source in the editor.
PDF import in German Excel
| English | German |
|---|---|
| Data > Get Data > From File > From PDF | Daten > Daten abrufen > Aus Datei > Aus PDF |
| Navigator, Load, Load To | Navigator, Laden, Laden in |
| Transform Data | Daten transformieren |
| Use First Row as Headers | Erste Zeile als Überschriften verwenden |
| Refresh All | Alle aktualisieren |
| Text to Columns | Text in Spalten |
Which Excel versions have this?
Microsoft's table of Power Query data sources lists the PDF connector on Windows only in the Microsoft 365 plans (Home, Personal, Business and Apps for Enterprise), not in Office 2016 or 2019. PDF does not appear in the list for Excel for Mac. According to the same overview, Excel for the web can get PDF files stored in SharePoint or OneDrive for work or school with an organizational account.
Frequently asked questions
Can I import several PDFs at once?
Yes, but not with From PDF. Microsoft recommends the Folder connector: Data > Get Data > From File > From Folder, which combines all files in the folder into one table.
How do I get back into the editor later?
Click in the loaded table and choose Query > Edit. Or open Data > Queries & Connections, right-click the query and choose Edit.
Does the link to the PDF stay?
Yes. The query stores the path to the file and every step. Refresh All reads the PDF again.
What about the other direction, from Excel into a document?
How to paste, link or embed an Excel table in Word is covered in Excel table in Word.