{"id":45877,"date":"2026-11-10T08:22:08","date_gmt":"2026-11-10T08:22:08","guid":{"rendered":"https:\/\/www.withdata.com\/blog\/?p=45877"},"modified":"2026-11-10T08:22:08","modified_gmt":"2026-11-10T08:22:08","slug":"csv-opens-in-excel-wrong","status":"publish","type":"post","link":"https:\/\/www.withdata.com\/blog\/datafileconverter\/csv-opens-in-excel-wrong.html","title":{"rendered":"CSV in Excel: The Zeros, the 15-Digit Barcode, and the Date That Moves"},"content":{"rendered":"<p>A CSV is text. Excel is not a text editor: the moment it opens a <code>.csv<\/code> it parses every field into a value \u2014 a number, a date, a boolean \u2014 and the text you sent is gone. Three things go wrong in that parse, and all three look like corruption:<\/p>\n<table>\n<thead>\n<tr>\n<th>What you sent<\/th>\n<th>What Excel shows<\/th>\n<th>Why<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><code>01234<\/code><\/td>\n<td><code>1234<\/code><\/td>\n<td>it is a number, so the leading zero is not part of the value<\/td>\n<\/tr>\n<tr>\n<td><code>000123456789012<\/code><\/td>\n<td><code>1.23457E+14<\/code><\/td>\n<td>more than 15 significant digits; Excel keeps 15 and shows the rest in scientific notation<\/td>\n<\/tr>\n<tr>\n<td><code>03\/04\/2024<\/code><\/td>\n<td>another day, depending on the machine<\/td>\n<td>dates are parsed with the local regional setting<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>The people who hit this have a common answer, and it is not a good one. In the r\/excel thread about Excel changing values on open (2026-08, 47 comments), the top reply with 55 upvotes says: <em>&#8220;Use Power Query \u2026 <strong>Set the column to Text, then import<\/strong>.&#8221;<\/em> The 26-point reply is blunter: <em>&#8220;Excel is not a CSV editor\u2026 if the exact CSV content matters, then don&#8217;t import to Excel at all.&#8221;<\/em> An ex-Excel tester in the same thread adds that the CSV reader code is 20 years old and nobody dares change it.<\/p>\n<p>So the real choice is not &#8220;which setting in Excel&#8221; but <strong>what you hand over<\/strong>.<\/p>\n<h2>1. Three ways out, and only one scales<\/h2>\n<p><strong>Route one \u2014 Power Query, every time.<\/strong> It works, and it is the answer the subreddit gives. It is also four dialogs per file, done again for the next file, and it depends on the person on the other end knowing that <em>Set column to Text<\/em> is the point.<\/p>\n<p><strong>Route two \u2014 tell them not to use Excel.<\/strong> A text editor shows the raw characters. It also does not produce something you can send to a customer, and nobody is going to read a five-column file as text.<\/p>\n<p><strong>Route three \u2014 hand over a spreadsheet that is already typed.<\/strong> Convert the CSV to <code>.xlsx<\/code> once, with the identifier columns stored as text and the numeric columns stored as numbers. Excel does not re-parse an <code>.xlsx<\/code>: what is in the cell is what the person sees, and every downstream copy, pivot and filter keeps it. One conversion, no settings, everyone opens the same file.<\/p>\n<p>That is the route this article is about, and it is a two-step job: <strong>decide the type of each column<\/strong> (this is where the CSV failed you), then write the workbook.<\/p>\n<h2>2. A CSV converted properly<\/h2>\n<p>Take a file that has all three problems in four rows:<\/p>\n<pre><code>order_id,zip,part_no,customer,note,qty,amount,shipped\n1001,01234,0001234567,\"ACME, Inc.\",plain,3,0.10,2026-03-01\n1002,00501,0009988776,Smith &amp; Sons,\"has, comma and \"\"quotes\"\" inside\",1,0.50,2026-03-02\n1003,90210,1234567890,Nguyen Ltd,,0,1234.56,\n1004,00012,0000000001,\u00d3 Briain Teo.,accented name,7,99.99,2026-03-05<\/code><\/pre>\n<p>Open it as a source in <a href=\"https:\/\/www.withdata.com\/data-file-converter\/\" target=\"_blank\" rel=\"noopener noreferrer\">DataFileConverter<\/a> \u2014 the preview is the file as text, with the header row already detected:<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.withdata.com\/wp\/wp-content\/uploads\/2026\/11\/csvinexcel-01-open-source.png\" alt=\"Open Source: orders.csv, Field Name In File Header checked, preview showing 01234 and 0001234567\" width=\"776\"><\/p>\n<p>On the Excel side there are only three settings that matter, and one of them is the heading:<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.withdata.com\/wp\/wp-content\/uploads\/2026\/11\/csvinexcel-02-set-target.png\" alt=\"Set Target: Heading On Excel Sheet checked, Excel Date Format, and the Source Date Format column\" width=\"776\"><\/p>\n<p><code>Heading On Excel Sheet<\/code> writes the first row as column names (leave it off and the names become a data row). The Columns Map gives one row per field, with <code>Source Date Format<\/code> where the field is a date \u2014 handy in \u00a74. Then <code>Convert Data<\/code>:<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.withdata.com\/wp\/wp-content\/uploads\/2026\/11\/csvinexcel-03-convert.png\" alt=\"Convert Data: 4 records, elapsed 0.016 seconds, from orders.csv to orders_safe.xlsx\" width=\"776\"><\/p>\n<h2>3. What ends up in the cells<\/h2>\n<p>Here is the converted sheet, read back from the <code>.xlsx<\/code> itself (not from the screen):<\/p>\n<table>\n<thead>\n<tr>\n<th>Column<\/th>\n<th>Stored as<\/th>\n<th>First value<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><code>order_id<\/code><\/td>\n<td>number<\/td>\n<td><code>1001<\/code><\/td>\n<\/tr>\n<tr>\n<td><code>zip<\/code><\/td>\n<td><strong>text<\/strong><\/td>\n<td><code>01234<\/code><\/td>\n<\/tr>\n<tr>\n<td><code>part_no<\/code><\/td>\n<td><strong>text<\/strong><\/td>\n<td><code>0001234567<\/code><\/td>\n<\/tr>\n<tr>\n<td><code>customer<\/code><\/td>\n<td>text<\/td>\n<td><code>ACME, Inc.<\/code><\/td>\n<\/tr>\n<tr>\n<td><code>note<\/code><\/td>\n<td>text<\/td>\n<td><code>has, comma and \"quotes\" inside<\/code> (one cell)<\/td>\n<\/tr>\n<tr>\n<td><code>qty<\/code><\/td>\n<td>number<\/td>\n<td><code>3<\/code><\/td>\n<\/tr>\n<tr>\n<td><code>amount<\/code><\/td>\n<td>number<\/td>\n<td><code>0.1<\/code><\/td>\n<\/tr>\n<tr>\n<td><code>shipped<\/code><\/td>\n<td>text\/date<\/td>\n<td><code>2026-03-01<\/code><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>The two decisions are local and mechanical: a column whose values start with a zero, or run to more than 15 digits, is an identifier and stays text; a column that is numeric throughout \u2014 and does not lose anything by being a number \u2014 is written as a number, so <code>SUM()<\/code> works in the workbook you send.<\/p>\n<p>That last part is the difference between &#8220;export as text&#8221; and &#8220;convert properly&#8221;: a file where <em>every<\/em> column is text is safe and useless (nobody can total the <code>amount<\/code> column), and a file where every column is auto-typed is exactly the CSV problem again. A 19-digit id is text for the same reason as the leading zero: Excel holds 15 significant digits, so <code>1234567890123456789<\/code> written as a number comes back rounded.<\/p>\n<h2>4. When there are dates<\/h2>\n<p>Dates are the case where the <em>reader&#8217;s<\/em> machine decides the meaning. <code>03\/04\/2024<\/code> is 3 April in most of Europe and 4 March in the US, and the same file opens differently on two desks.<\/p>\n<p>So the format is a setting, not a guess:<\/p>\n<ul>\n<li><code>Source Date Format<\/code> (on the Columns Map, per column) tells the converter how to read the text \u2014<\/li>\n<\/ul>\n<p><code>dd\/mm\/yyyy<\/code> for <code>03\/04\/2024<\/code> = 3 April;<\/p>\n<ul>\n<li><code>Excel Date Format<\/code> tells it what to write \u2014 <code>dd.mm.yyyy<\/code> produces <code>03.04.2024<\/code>.<\/li>\n<\/ul>\n<p>Set both and the same input produces the intended day on any machine. Leave them alone and the value is carried through as written, which is also defensible: a date that stays text cannot move.<\/p>\n<h2>5. From the command line<\/h2>\n<pre><code>DataFileConverter.exe convert --from=orders.csv --to=orders_safe.xlsx<\/code><\/pre>\n<p>The same session, with the same type decisions, for a nightly export. On Windows the desktop binary takes the verb directly \u2014 no separate command-line build.<\/p>\n<h2>FAQ<\/h2>\n<h3>Why does Excel change <code>01234<\/code> to <code>1234<\/code>?<\/h3>\n<p>Because it parses the field as a number, and a number does not have leading zeros. Nothing is corrupted: the value <code>1234<\/code> is what Excel believes you sent. Only a text cell keeps <code>01234<\/code>.<\/p>\n<h3>Why does a 15-digit code turn into <code>1.23457E+14<\/code>?<\/h3>\n<p>Excel keeps 15 significant digits and displays longer numbers in scientific notation. A 16-digit card or barcode number is already being rounded in the cell. Store identifiers of that length as text.<\/p>\n<h3>Can I stop Excel from doing this when opening a CSV?<\/h3>\n<p>Not with a global setting \u2014 there is no &#8220;always treat CSV fields as text&#8221; switch, which is what the r\/excel thread is complaining about. Importing through Power Query with the column set to Text works per file; a converted <code>.xlsx<\/code> works without any step at all.<\/p>\n<h3>Will the converted file still open on a Mac or in Google Sheets?<\/h3>\n<p>Yes: <code>.xlsx<\/code> carries the cell type with the value, so every spreadsheet application shows the same thing. The type is in the file, not in the reader&#8217;s settings.<\/p>\n<h3>What about a CSV that has no header row?<\/h3>\n<p>Leave <code>Field Name In File Header<\/code> unticked, and the converted sheet has no heading row either \u2014 the first row of data stays the first row.<\/p>\n<h3>Can I put the data into a database instead of a spreadsheet?<\/h3>\n<p>That is the other direction: <a href=\"https:\/\/www.withdata.com\/file-to-db\/\" target=\"_blank\" rel=\"noopener noreferrer\">FileToDB<\/a> imports CSV into MySQL, PostgreSQL, SQL Server and others, with the column types chosen in the same way.<\/p>\n<h2>Stop converting by hand<\/h2>\n<blockquote>\n<p><strong>Hand over a spreadsheet that opens with the zeros, the digits and the dates intact.<\/strong> <a href=\"https:\/\/www.withdata.com\/data-file-converter\/\" target=\"_blank\" rel=\"noopener noreferrer\">Try DataFileConverter<\/a> \u2014 CSV, TSV, fixed-width, Excel, JSON, XML and SQL in either direction; Windows \/ macOS \/ Linux, one-time price.<\/p>\n<\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>A CSV is text. Excel is not a text editor: the moment it opens a .csv it parses every field into a value \u2014 a number, a date, a boolean \u2014 and the text you sent is gone. Three things go wrong in that parse, and all three look like corruption: What you sent What [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1477],"tags":[13865,1502,13751,13866],"class_list":["post-45877","post","type-post","status-publish","format-standard","hentry","category-datafileconverter","tag-csv-leading-zeros","tag-csv-to-excel","tag-datafileconverter","tag-excel-changes-csv"],"_links":{"self":[{"href":"https:\/\/www.withdata.com\/blog\/wp-json\/wp\/v2\/posts\/45877","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.withdata.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.withdata.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.withdata.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.withdata.com\/blog\/wp-json\/wp\/v2\/comments?post=45877"}],"version-history":[{"count":1,"href":"https:\/\/www.withdata.com\/blog\/wp-json\/wp\/v2\/posts\/45877\/revisions"}],"predecessor-version":[{"id":45878,"href":"https:\/\/www.withdata.com\/blog\/wp-json\/wp\/v2\/posts\/45877\/revisions\/45878"}],"wp:attachment":[{"href":"https:\/\/www.withdata.com\/blog\/wp-json\/wp\/v2\/media?parent=45877"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.withdata.com\/blog\/wp-json\/wp\/v2\/categories?post=45877"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.withdata.com\/blog\/wp-json\/wp\/v2\/tags?post=45877"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}