Skip to content

Data not rendering in excel if previous column contain a # #60

@marshallshelly

Description

@marshallshelly

Issue

If a column contained a # somewhere, it would not render the remaining characters and the next columns' data.

To reproduce

Used dataset

        const res = [
          {
            id: "468fe976-c50b-45a3-a7f0-2e7fa21bc3ea",
            brand: "Acute",
            campaign: "Campaign #1",
            round: 1,
            username: "Fairy",
            createdAt: "2023-10-17T06:41:08.474Z",
            visits: 0,
            timeSpend: "0 seconds",
          },
        ];

Used Code

        const parser = new AsyncParser({
          fields: [
            {
              label: "ID",
              value: "id",
            },
            {
              label: "Brand",
              value: "brand",
            },
            {
              label: "Campaign",
              value: "campaign",
            },
            {
              label: "Round",
              value: "round",
            },
            {
              label: "Username",
              value: "username",
            },
            {
              label: "Visits",
              value: "visits",
            },
            {
              label: "Time Spend",
              value: "timeSpend",
            },
            {
              label: "Created On",
              value: "createdAt",
            },
          ],
        });
        const csv = await parser.parse(res).promise();

        reply.header("Content-disposition", "attachment; filename=data.csv");
        reply.header("Content-Type", "text/csv");
        return reply.send(csv);

In my dataset, there is # in the campaign, so the subsequent columns' data won't render.
image
If I take out the #, then everything renders
image

Any reason why this is happening?

P.S I'm viewing the CSV in Microsoft Excel

Versions

@json2csv/node: 7.0.3
nodejs: 18

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions