Sub topic 2
Which file formats Google Sheets can import
This chapter assumes you can upload files to Google Drive and know the difference between a workbook and a delimited text file. It covers which formats Google Sheets accepts, how it treats each family, and what you lose when a format is not accepted. The File > Import dialog itself is the next chapter's topic.
Two families of files
Every importable format belongs to one of two families. The family decides what Sheets can read from the file.
- Workbook files are spreadsheet documents. They hold several sheets, cell types, formulas, number formats, colors, and sometimes charts or macros. Examples are
.xlsx,.xls, and.ods. - Delimited text files are plain text. Each line is a row, and a separator character splits each row into cells. Examples are
.csv,.tsv, and.txt. They hold no formatting, no formulas, and no sheet structure. Every value is just a string of characters.
This difference explains most import problems. A workbook already says "this cell is a date" or "this cell is the number 1,200". A text file says nothing. Sheets has to guess the type of each value from its characters, and wrong guesses cause the problems in the type pitfalls chapter.
The supported formats
The table lists the formats Sheets reads. Google's help pages list a few more spreadsheet extensions than the Import dialog's own labels do, so check your own account if a rare extension matters to you.
| Extension | Family | What it is | Notes |
|---|---|---|---|
| `.xlsx` | Workbook | Excel 2007 and later (Open XML) | The most common and best supported workbook format |
| `.xls` | Workbook | Excel 97 to 2003 (binary) | Older format, supported for conversion |
| `.xlsm` | Workbook | Excel workbook with macros | Data and formulas convert. VBA macros do not run |
| `.ods` | Workbook | OpenDocument spreadsheet | Used by LibreOffice and OpenOffice |
| `.csv` | Delimited text | Comma-separated values | Default separator is a comma |
| `.tsv` | Delimited text | Tab-separated values | Tab separator |
| `.txt` | Delimited text | Plain text with a separator | Treated as delimited text. Separator is detected or chosen |
| `.tab` | Delimited text | Tab-delimited text | Behaves like `.tsv` |
Excel template extensions such as .xltx are also accepted by Drive's conversion. They behave like .xlsx files.
Formats Sheets cannot import
Some formats look like spreadsheet data but cannot be imported directly. Convert them first.
.xlsb(Excel Binary Workbook) is not supported. Open it in Excel and save it as.xlsx..numbers(Apple Numbers) is not supported. Export it from Numbers as Excel or CSV..jsonand.xmlare structured data, not grids. Sheets has no import path for them in the dialog. Convert them to CSV with a script, or use Apps Script to parse them.- Fixed-width text files have no separator character. Sheets would put each whole line in one cell. Open them in a text tool and convert them to a delimited format first.
- Password-protected or encrypted workbooks cannot be converted. Remove the password in Excel first.
.pdfis a document format, not a spreadsheet. Extracting tables from it needs a separate tool.
The next callout covers a case that surprises many people.
How Sheets decides what a file is
Sheets looks at the file extension and at the content. A few consequences follow.
- The extension chooses the parser. A file named
report.csvis parsed as delimited text. A file namedreport.xlsxis parsed as a workbook. If you rename a CSV to.xlsx, the import fails because the content is not a valid zipped Open XML package. .txtis ambiguous. A text file could use commas, tabs, semicolons, or pipes. Sheets can detect the separator, or you can set it yourself in the import dialog. Detection can be wrong on files with few rows or with commas inside the text, so set it explicitly when the result looks off.- MIME type matters in Drive. Drive stores an uploaded file with a MIME type, such as
text/csvorapplication/vnd.openxmlformats-officedocument.spreadsheetml.sheet. Apps Script and the Drive API use this type when they filter or convert files.
Two routes into Sheets: open versus import
The same file can enter Sheets in two ways, and the result differs.
- Open from Drive. You upload an
.xlsxfile to Drive and open it with Sheets. Sheets shows it in compatibility mode. The file stays an Excel file until you choose File > Save as Google Sheets. Edits go back to the.xlsxfile. - Import. You use File > Import, which reads the data and creates or changes a native Google Sheets file. The original file is untouched.
For delimited text, opening a .csv from Drive shows a preview and creates a Sheets file. Import gives you the controls you need for separators and for where the data lands. Workbook conversion is covered in a later chapter. Here the point is that the format family limits which options you get.
| Option | Workbook files | Delimited text files |
|---|---|---|
| Choose a separator | Not applicable | Yes |
| Convert text to numbers, dates, and formulas | Not applicable, types are stored in the file | Yes |
| Several sheets in one file | Yes, each sheet becomes a tab | No, one table per file |
| Formulas carried over | Yes, if Sheets supports the function | No, formula-like text is only converted if you allow it |
| Formatting carried over | Mostly | None |
Inspecting a file before you import it
Before importing a mystery text file, look at it. A short script saves a failed import. This Python example reads the start of a file, checks for a byte order mark, and guesses the delimiter.
import csv
import sys
def inspect(path):
with open(path, "rb") as f:
raw = f.read(4096)
if raw.startswith(b"\xef\xbb\xbf"):
encoding = "utf-8-sig"
print("Encoding: UTF-8 with BOM")
else:
try:
raw.decode("utf-8")
encoding = "utf-8"
print("Encoding: valid UTF-8")
except UnicodeDecodeError as err:
encoding = "latin-1"
print("Encoding: not UTF-8 (%s), trying Latin-1" % err)
sample = raw.decode(encoding, errors="replace")
try:
dialect = csv.Sniffer().sniff(sample, delimiters=",;\t|")
print("Delimiter: %r" % dialect.delimiter)
except csv.Error:
print("Delimiter: could not be detected")
if __name__ == "__main__":
inspect(sys.argv[1])Run it as python inspect_file.py data.csv. If it reports a semicolon, choose "Custom" or "Semicolon" as the separator when you import. If it reports a non-UTF-8 encoding, re-save the file as UTF-8 before importing. The encoding chapter explains why.
A decision path
The diagram shows how the format leads to a method.
Size and structure limits that depend on format
The limits chapter gives the exact numbers, so this section only lists the structural points that affect which format to pick.
- A Google Sheets file has a cap on total cells. A large
.csvthat exceeds it will fail or be cut off, no matter which family it belongs to. - A workbook with many sheets turns into one tab per sheet. Each tab counts toward the cell cap.
- Workbook files carry hidden sheets, defined names, and styles. These add weight and can behave differently after conversion.
- Delimited files have no such extras, so they are smaller and more predictable. This is why a CSV export is often the safer choice for plain tabular data.
Choosing a format when you have a choice
You often get to decide how a colleague or a system exports data. Use these criteria.
- Do you need formulas or several sheets? Use
.xlsx. CSV cannot hold either. - Do the values contain leading zeros, long ID numbers, or mixed dates? Prefer
.xlsx, because it stores the type of each cell. If you must use CSV, plan to set the type conversion option off and format columns by hand. - Will the file be re-imported often by a script? Prefer CSV. It is easy to parse with
Utilities.parseCsvand easy to compare line by line. - Is the data very large? Prefer CSV, which carries no styling overhead, but check the cell limit first.
- Does the source use a regional number format? CSV leaves the interpretation to Sheets' locale. An
.xlsxfile stores numbers in a locale-neutral way, so it is less sensitive to the setting.
Last, a note on .txt. Many systems label any export as .txt. Treat such a file as delimited text with an unknown separator until you have looked at it.
Common mistakes with formats
- Renaming instead of converting. Changing
.xlsbto.xlsxin the file name does not convert it. The import fails with a format error. - Assuming CSV means commas. In several locales, Excel writes semicolons and calls the file CSV. Check the first line.
- Expecting macros to survive. See the warning above.
- Trusting the preview as a type guide. For text files the preview only shows how Sheets guessed. Check the real cell types after import.
- Importing a file with multiple tables in a text file. A CSV has one grid. If someone pasted two tables with a blank line between them, Sheets loads both into the same sheet. Split them first.
Exercise
A colleague sends inventory.xlsb, and you try File > Import. It fails. They suggest renaming the file to inventory.xlsx. Will that work, and what should you do instead?
Show answer
Renaming will not work. The .xlsb format is a binary Excel format that Sheets does not support, and a renamed file still has binary content, so the parser rejects it. Ask the colleague to open the file in Excel and use Save As to produce a real .xlsx file (or a CSV if only the data matters). Then import that file.
Exercise
You receive orders.txt. Its first line is id;customer;total. Which family does the file belong to, and what must you check or set before importing it?
Show answer
It is delimited text, because .txt is treated that way. The separator is a semicolon, not a comma, so you must choose a semicolon or a custom separator in the import dialog. Otherwise every line lands in one cell. You should also confirm the encoding is UTF-8.
Exercise
You need to bring in a data file where the ZIP code column contains values like 02134. Would you request .xlsx or .csv from the source, and why?
Show answer
Prefer .xlsx, because it stores the cell type, so the ZIP code stays text and keeps its leading zero. With CSV, Sheets may read 02134 as the number 2134 unless you turn off type conversion or reformat the column afterwards.