Spreadsheets, CSV, and tabular interchange
Excel workbooks (.xlsx, .xls) store grids as structured packages: sheets, shared strings, styles, and formulas. Comma-separated values (CSV) is a plain-text interchange format—one row per line, fields separated by delimiters—ideal for git, databases, and APIs that do not speak OOXML.
Exporting a sheet to CSV drops most workbook features (formulas become last calculated values, multiple tabs become one slice, charts and macros disappear). For pasted JSON or CSV text both ways, use JSON to CSV; to rebuild .xlsx or preview charts, pair with CSV to Excel or CSV charts.
Excel and CSV — background
Inside an XLSX workbook (OOXML package)
- An .xlsx file is a ZIP archive of XML parts: workbook metadata, per-sheet grid data, shared string tables, and style sheets.
- Cells reference shared strings by index to deduplicate repeated labels; numbers and booleans often live inline in sheet XML.
- Legacy .xls uses a binary BIFF record stream—parsers map both formats into the same row/column model for export.
- Macros (.xlsm), external links, and embedded objects may not survive a CSV round trip even when the sheet grid reads fine.
Cell values, serial dates, and display formats
- Excel stores dates as serial numbers from an epoch; CSV export typically emits the displayed text or ISO-like strings depending on locale settings.
- Leading zeros on IDs (SKU 007) live as text cells—CSV must quote those fields or Excel may coerce them to numbers on re-import.
- Formulas export as calculated results unless you copy “formula text” manually; CSV has no formula syntax.
- Merged cells flatten to the top-left value in many exporters; blank trailing rows/columns may be trimmed.
CSV rules: quoting, commas, and RFC 4180 habits
- Fields containing comma, quote, or newline must be wrapped in double quotes; internal quotes double up ("").
- Header row is conventional but not mandatory—downstream tools infer column names from the first line.
- European Excel often saves “CSV (semicolon)” when the OS decimal separator is comma—same data, different delimiter.
- Tab-separated values (.tsv) follow the same escaping idea with tab as the field separator.
UTF-8, BOM, and reopening CSV in Excel
- UTF-8 encodes all Unicode scripts in one byte stream; without a hint Excel on Windows may guess a legacy code page and mangle CJK text.
- A UTF-8 BOM (byte order mark) at file start signals UTF-8 to Excel’s text importer—common fix for Chinese/Japanese/Korean columns.
- “Data → From Text/CSV” lets you pick delimiter and encoding when double-click open mis-parses columns.
- Unix line endings (LF) vs Windows (CRLF) rarely change column semantics but affect diff tools and strict parsers.
Where CSV export fits
Commit-friendly tables for git and CI
Small reference datasets diff cleanly as CSV in pull requests after exporting one sheet from a workbook.
Hand off to JSON pipelines or charts
Load CSV into JSON to CSV for array JSON, or visualize the same rows in CSV charts before editing in CSV to Excel.