How to convert CSV to Excel without formatting errors
Opening a raw CSV directly in desktop Excel triggers automatic type guessing that strips leading zeros from ZIP codes, turns 16-digit order IDs into scientific notation, and garbles accented characters. Converting CSV to XLSX in your browser locks every cell to its proper XML type before Excel ever opens the file.
Because plain text files registered under the IANA text/csv Media Type Registration carry no schema or encoding header, Excel guesses delimiters and data types from your operating system locale. Building a native .xlsx workbook stores text cells and numeric cells explicitly, so SUM() formulas work while postal codes and UTF-8 names stay exact.
Unlike cloud converters that upload customer lists or financial tables to remote servers, this tool runs inside a local Web Worker. If you ever need to go the opposite direction and export a finished workbook back to delimited text, use Excel to CSV in the same browser session.
| Spreadsheet behavior | Opening raw CSV in Excel | Converting with CSV to Excel |
|---|---|---|
Leading-zero ZIP codes (02138) |
Stripped to 2138 |
Preserved as exact text (02138) |
| 16-digit card or order IDs | Rounded after 15 digits | Preserved as exact inlineStr text |
UTF-8 accents (Café, München) |
Often garbled without BOM | Decoded cleanly as UTF-8 XML |
| Semicolon or tab files | Often jammed into Column A | Auto-detected (,, ;, \t) |
| Header row and column widths | Unstyled, narrow default width | Bold Calibri header, 8–60 char width |
Keeping leading zeros and 16-digit IDs intact
Spreadsheet users often face an annoying trade-off: store everything as text and break SUM() formulas, or convert numbers and lose leading-zero identifiers. Checking Turn numbers into real numbers (so formulas add up) applies a strict numeric filter so only safe values become numeric cells.
How Turn numbers into real numbers handles formulas vs codes
When the checkbox is enabled, isSafeSpreadsheetNumber() verifies that a cell matches a standard integer or decimal without leading zeros. Values such as 42, -19.95, and 0 become real <v> numeric cells that work in SUM, AVERAGE, and charts, whereas 02138 or 00412 stay as text.
If your data starts as an XML feed rather than a CSV, you can also turn XML feeds into formatted Excel tables using the same type-safe workbook writer.
IEEE-754 precision limits beyond 15 significant digits
JavaScript numbers and Excel’s internal numeric cells both rely on 64-bit IEEE-754 floating-point storage, which guarantees exact integers only up to MDN Number.MAX_SAFE_INTEGER IEEE-754 Reference (53 bits, or roughly 15 significant digits).
To prevent Excel from truncating long numbers in CSV exports, any value exceeding 15 significant digits is written as an inlineStr text cell instead of a numeric <v> tag. That keeps 16-digit card numbers, tracking codes, and bank references intact.
Tip: Uncheck Turn numbers into real numbers (so formulas add up) if you are importing raw barcode catalogs or phone directories where no arithmetic formulas are needed.
Auto-detecting delimiters, UTF-8 text, and quote errors
Real-world exports arrive from European ERP systems with semicolons, from database dumps with tabs, or from UTF-8 pipelines with a leading Byte Order Mark (0xFEFF). The parser normalizes all three inputs automatically before building the spreadsheet.
Comma, semicolon, and tab detection for CSV and TSV
When you drop a .csv, .tsv, or .txt file, detectDelimiter() inspects the text to identify whether columns are separated by commas, semicolons, or tabs. Both quoted multiline fields and escaped double quotes ("") follow the IETF RFC 4180 CSV Format Specification.
Pinpointing unclosed quotes and stripping UTF-8 BOMs
A leading UTF-8 BOM is stripped cleanly so it never pollutes cell A1 with invisible characters. If a malformed export leaves a quotation mark unclosed, unclosedQuoteLine() halts conversion and reports the exact line number, while if you also need to convert Markdown notes to Word for the same report package, you can do so locally.
Native XLSX styling, column widths, and sheet naming
Instead of producing a bloated HTML table disguised with an .xls extension, the worker writes genuine Office Open XML parts inside a compressed .xlsx container. Every workbook opens without Excel’s “file format and extension don’t match” warning.
Bold header rows and 8 to 60 character column fitting
Row 1 (r === 0) receives bold Calibri 11 pt styling (s="1") so column headers stand out immediately when you open the sheet in Microsoft Excel, Google Sheets, LibreOffice Calc, or Apple Numbers.
Column widths are measured across every cell and clamped between 8 and 60 characters (<col customWidth="1"/>) so headers and values remain readable without manual resizing. Empty trailing rows at the end of a CSV are trimmed automatically so blank lines never inflate the worksheet.
Sanitizing worksheet names and XML control characters
Excel rejects worksheet names containing \, /, ?, *, [, ], or :, names longer than 31 characters, and the reserved name History (which is renamed to History_sheet). The workbook builder cleans your filename to meet those rules, strips disallowed XML 1.0 control characters so spreadsheets open cleanly everywhere, and lets you bundle converted workbooks into a ZIP afterward when delivering multiple spreadsheets to clients or teammates.