From CSV text to an XLSX workbook
Comma-separated values are a line-oriented interchange format; an .xlsx file is a structured OOXML package with sheets, cell grids, and optional styling. Turning CSV into xlsx maps the first row to column headers and each following line to data rows on Sheet1—no formulas, charts, or multiple tabs unless you add them later in Excel.
Use Excel to CSV to export spreadsheets the other way, JSON to CSV when the source is JSON arrays, or CSV charts to visualize the same table before building a workbook.
CSV import and XLSX structure
How a CSV grid becomes sheet.xml inside xlsx
- Parsers split each line into fields using a delimiter (comma, semicolon, or tab) while honoring quoted segments that contain separators.
- The first row typically supplies column names; subsequent rows align values to those headers by position.
- SheetJS-style writers emit a worksheet as a sparse cell table (A1, B1, …) and wrap it in workbook.xml inside the ZIP package.
- A minimal export creates one worksheet (often Sheet1) without macros, pivot tables, or external links.
Cell types when CSV lands in Excel
- Plain CSV importers usually store every field as text or general-format cells—Excel may later auto-convert numbers and dates on edit.
- Leading-zero IDs stay safe when the CSV quoted the field; unquoted numeric-looking tokens may become numbers after open.
- Boolean literals (true/false) and null from JSON-derived CSV often remain strings unless you format columns in Excel.
- There is no formula language in CSV—imported sheets start as values only.
Delimiter detection and header conventions
- Auto-detection compares comma, semicolon, and tab counts on the first line—European exports often prefer semicolon when comma is the decimal separator.
- RFC 4180-style quoting wraps fields that embed commas, quotes, or newlines; doubled quotes escape a literal quote character.
- UTF-8 with BOM on the CSV file helps editors; the generated xlsx stores Unicode in shared strings regardless.
- Empty trailing columns or ragged rows may produce blank cells or uneven row widths depending on parser rules.
What xlsx adds beyond the CSV bytes
- Workbooks can hold multiple sheets, named ranges, and column widths—CSV carries none of that metadata.
- Excel recalculates formulas only after you type them; imported CSV never revives formulas from a prior xlsx export.
- Opening the same xlsx in LibreOffice, WPS, or Google Sheets may differ slightly in default column width and date parsing.
- Large CSV files produce large sheet XML—compression in the ZIP still beats raw CSV for very wide repeated text columns sometimes.
When CSV → xlsx helps
Share a table as an attachment
Recipients expect .xlsx in email or ticket systems even when your pipeline outputs UTF-8 CSV.
Round-trip with export and charts
Edit CSV as text, rebuild xlsx here, or export from Excel to CSV and chart the same rows in CSV charts.