The short answer
- CSV is a text data format that separates fields with commas, but it does not preserve a workbook’s formatting or multiple worksheets.
- Excel can open CSV directly or import it through From Text/CSV, where you can select a delimiter and preview the result. Direct opening applies default column interpretation, which can change dates or remove leading zeros. Specify column types during import when those details matter.
- CSV is passive text, but spreadsheet software may interpret untrusted cells as formulas. OWASP describes risks including data exfiltration and, when combined with vulnerabilities or ignored warnings, computer compromise. Ordinary CSV quoting is not universal protection against formula injection.
CSV files: opening, importing and converting
RFC 4180 documents common CSV structure and registers text/csv. Records may start with a header row and normally use CRLF line endings; each record should have the same number of fields. Fields containing commas, line breaks or double quotes should be enclosed in double quotes, with internal double quotes doubled.
To convert CSV to XLSX in Excel, import it, check column interpretation and save as XLSX. This cannot restore formatting or worksheets absent from the CSV. Exporting a workbook to CSV saves only the active sheet’s displayed text and values; formatting, graphics and objects are lost.
How to open it
Excel can open CSV directly or import it through From Text/CSV, where you can select a delimiter and preview the result. Direct opening applies default column interpretation, which can change dates or remove leading zeros. Specify column types during import when those details matter.
Excel can open CSV directly or import it through From Text/CSV, where you can select a delimiter and preview the result. Direct opening applies default column interpretation, which can change dates or remove leading zeros. Specify column types during import when those details matter.
To convert CSV to XLSX in Excel, import it, check column interpretation and save as XLSX. This cannot restore formatting or worksheets absent from the CSV. Exporting a workbook to CSV saves only the active sheet’s displayed text and values; formatting, graphics and objects are lost.
File safety
CSV is passive text, but spreadsheet software may interpret untrusted cells as formulas. OWASP describes risks including data exfiltration and, when combined with vulnerabilities or ignored warnings, computer compromise. Ordinary CSV quoting is not universal protection against formula injection.
An unknown sender, a name ending in two extensions, or contents that do not match the extension — check before you open it.
Converting it
To convert CSV to XLSX in Excel, import it, check column interpretation and save as XLSX. This cannot restore formatting or worksheets absent from the CSV. Exporting a workbook to CSV saves only the active sheet’s displayed text and values; formatting, graphics and objects are lost.
Convert a copy, never the original, then compare quality, metadata, and layout against what you started with.
Common questions
What is a CSV file?
CSV means Comma-Separated Values. It stores records as text with comma-separated fields and may include a header row. RFC 4180 documents its common structure.
How do I open a CSV file in Excel?
Open it directly in Excel, or use From Text/CSV to choose the delimiter and preview columns. Use import with explicit column types when dates or leading zeros must be preserved.
How do I open a CSV file on Windows?
If you have Excel on Windows, open the CSV from Excel. For control over column interpretation, use From Text/CSV and check the preview before importing.
How do I open a CSV file on Mac?
If you use Excel on Mac, open the CSV in Excel and check dates and numeric identifiers. Where your version offers text/CSV import, use its preview and column settings for more control.
Why does a CSV file open in one column in Excel?
Check whether the selected delimiter matches the file. Import through From Text/CSV, select the appropriate delimiter and inspect the preview before loading.
What should I do if Chinese text in a CSV file looks garbled in Excel?
Try From Text/CSV and check the preview. If the text is still garbled, an encoding mismatch may be the cause. Ask the sender which character encoding they used and request a new export with readable Chinese text; check the preview again before loading.
How do I preserve leading zeros in CSV when importing into Excel?
Import the CSV and explicitly set identifier columns to text. Direct opening uses default interpretation and may remove leading zeros or interpret values as dates.
CSV versus XLSX: which should I use?
Use CSV for text records arranged in fields. Choose XLSX when you need a workbook with multiple worksheets and formatting; CSV export does not retain those workbook features.
How do I convert CSV to XLSX in Excel?
Import the CSV, verify column types and values, then save as XLSX. Saving cannot recover formatting or additional worksheets that were never stored in the CSV.
What are the CSV formula injection risks in an untrusted file?
A spreadsheet may interpret cell content as formulas. OWASP lists data exfiltration and potentially computer compromise in combination with vulnerabilities or ignored warnings. Assess the source before opening untrusted CSV in a spreadsheet; ordinary quoting is not universal protection.
How should double quotes in CSV fields be escaped?
RFC 4180 describes enclosing fields containing commas, line breaks or double quotes in double quotes, then doubling each internal double quote. This structural escaping does not guarantee protection from formula injection.
Related formats
Sources
RFC 4180 — Common Format and MIME Type for Comma-Separated Values (CSV) Files · IETF 信息性 RFC
Import or export text (.txt or .csv) files · Microsoft 官方支持文档
Excel formatting and features that are not transferred to other file formats · Microsoft 官方支持文档
CSV Injection · OWASP Foundation 安全资料