Skip to content
This repository was archived by the owner on Jun 28, 2021. It is now read-only.
This repository was archived by the owner on Jun 28, 2021. It is now read-only.

Fields starting with equals (=) do not open correctly in Excel #103

Description

@kiprobinson

If a field value starts with equals character (=), the csv does not open correctly in Excel. This may technically be an Excel problem, but it would be nice if there was some kind of "excelSafe" option to csv-stringify.

Examples:

Field       CSV Encoding     What Excel Shows      Excel-safe CSV Encoding (causes Excel to show same as input)
=test       =test            #NAME?                "=""=test"""
="test"     "=""test"""      test                  "=""=""""test"""""""
="test      "=""test"        ="test                "=""=""""test"""

Workaround:

cast: {
    string: s => s.charAt(0) === '=' ? `="${s.replace(/"/g,'""')}"` : s,
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions