Settings

A PDF does not contain a table. It contains words, each drawn at a position on the page, and sometimes lines drawn between them. A converter has to guess which words form a row and where one column ends and the next begins, from the positions alone. When it guesses wrongly you get one of four results: everything in one column, columns split in the wrong places, several columns merged into one cell, or text that should be numbers. Each has a cause you can see in the PDF and a fix, and a scanned PDF has no words to find at all. COLUMNS finds columns from the table’s own ruled lines where it has them and from the gaps its rows share where it does not, in the browser tab.

What a converter has to work with

Inside a PDF, a line of a table is a series of instructions: move to this point, draw this run of characters in this font; move over there, draw that run. The runs can be whole cells, single words or single letters, depending on the program that made the PDF, and nothing marks where a cell starts. A converter groups runs that share a baseline into a row, then looks for vertical bands of the page that the words of most rows fall into and nothing crosses. Those bands are the columns.

That works well on a table with clear gaps between columns. It struggles on the kinds of table that are common in practice: long descriptions that wrap onto a second line, headings that span two columns, right-aligned amounts whose left edges wander, and statements laid out with spaces rather than positions.

The four ways it goes wrong

What you seeUsual causeWhat to do
Every row in column AThe table was laid out with runs of spaces, like a typewriter, so each row is one long string; or the converter treated the page as flowing textSplit it in Excel: Data, Text to Columns, Fixed width; or use a converter that splits at runs of spaces
Columns split in the middle of a fieldA wide gap inside one column (between a name and a reference, say) looked like a column edgeMerge the pieces back with a formula such as =B2&" "&C2, or convert again with ruled lines if the table has them
Two fields in one cell, or merged cellsNo gap wide enough between them on every row, or a heading spanning bothUnmerge (Home, Merge & Center, Unmerge Cells), then Text to Columns on the shared cell
Amounts that will not add upThey came across as text: thousands commas, currency signs, a trailing CR or DR, or brackets for negativesA converter that reads these as numbers; or =VALUE(SUBSTITUTE(A2,",","")) and Find and Replace

One more that looks like a converter fault and is not: the output is empty or full of nonsense characters. If you cannot select the text in the PDF with the mouse, it is a scan, a picture of a page, and there are no words for any converter to place. It needs OCR first; OPTIC gives a scanned page a text layer. If you can select the text but it pastes as gibberish, the PDF’s fonts have no mapping from their glyphs back to letters, and OCR is again the only way round.

Before converting, look at the table

  • Are there vertical lines between the columns? A table with ruled columns is the easiest case; a converter that uses the rules as column edges gets it right even when the gaps are uneven.
  • Do descriptions wrap onto two lines? The second line becomes a row of its own with only one column filled. Sort by a column that should never be empty, such as date or amount, and the stray lines gather together; join them to the row above and delete them.
  • Is it one table per page, with the heading repeated? Put every page on one sheet, then filter out the repeated heading rows.
  • Are there account numbers or codes with leading zeros? Keep those columns as text, or 00123 becomes 123.

Converting in the browser

COLUMNS reads the PDF in the tab, so a bank statement is not sent to anyone’s server. It puts words that share a line into a row, uses the table’s own vertical rules as column edges where the page draws them, and otherwise finds the bands nearly every row leaves empty, so that a heading crossing a gap is outvoted rather than merging two columns. A table laid out with runs of spaces is split at each run of two or more spaces, with each piece placed by its share of the line. Amounts with thousands separators, currency signs, brackets for negatives and percentages are stored as numbers with a matching format, so the sheet adds up.

You choose the pages, one sheet a page or all on one sheet, and whether to keep every cell as text for codes and account numbers. It writes an .xlsx or a CSV. A page with no words is named as probably scanned. Converting and looking at the result is free; saving it is part of OBSCURA Pro, or US$1 to save from one tool for a day.

No converter reads every table right, this one included. A statement whose descriptions wrap, or a report with nested headings, will still need the tidying above. Check the column totals against the PDF before relying on the sheet.

Questions people ask about Why a PDF table comes out wrong in Excel, and how to fix it

Why does my PDF to Excel conversion put everything in one column?

The table was probably laid out with runs of spaces, so each row is a single string, or the converter treated it as flowing text. Split it with Data, Text to Columns, Fixed width, or use a converter that splits rows at runs of spaces.

Why are the columns wrong after converting a PDF to Excel?

A PDF holds words at positions, not a table. The converter guesses columns from the gaps between words, and wide gaps inside a field or narrow gaps between fields fool it.

Why won't the numbers from my PDF add up in Excel?

They came across as text because of thousands commas, currency signs, brackets or CR and DR markers. Convert them with VALUE and SUBSTITUTE, or use a converter that reads them as numbers.

Why is my converted PDF empty or full of strange characters?

If you cannot select the text in the PDF, it is a scan and needs OCR first. If the text pastes as gibberish, the fonts have no mapping back to letters, and OCR is again the answer.

How do I stop account numbers losing their leading zeros?

Keep those columns as text during conversion, or format the column as Text before pasting. COLUMNS has a setting to keep every cell as text.

How do I fix descriptions that wrap onto a second row?

Sort by a column that should never be empty, such as the date, so the stray second lines gather together, join each to the row above and delete them.

Related

More on this

All 22 guides under “A file that will not open, or comes out wrong”.

A letter, now and then

An occasional letter when there is something worth reading: the new guides and what changed in the tools. Never more than once a month and nothing else, and you can leave at any time on the unsubscribe page.