pratik227/vue3-json-excel

number as string (text)

Closed this issue · 5 comments

Hi. I have a number like this: 04515153151
In export, the first digit (0) will be removed and the number will be like this: 4515153151.
how can I set the column format as string (text)?
I've tried to set "stringifyLongNum" as "true" but didn't make any changes.

Hi @msghaderi77 ,

  data() {
    return {
      json_data: data,
      json_fields: {
        "Complete name": "name",
        City: "city",
        Telephone: "phone.mobile",
        "Telephone 2": {
          field: "phone",
          callback: (value) => {
            return `'${value}`;
          },
        },
      },
      json_meta: [
        [
          {
            key: "charset",
            value: "utf-8",
          },
        ],
      ],
    }
  },

const data = [
  {
    name: "Tony Peña",
    city: "New York",
    country: "United States",
    birthdate: "1978-03-15",
    phone: "04515153151"
  },
]
    <JSONExcel :leading_zero="true" class="btn btn-default"
               :data="json_data"
               worksheet="My Worksheet" :fields="json_fields"
               name="filename.xls">Download Excel (you can customize this with html code!)
    </JSONExcel>

You can add something like this then only it will work you need's to convert it to some string Or you can add Whatever string you want.

Thanks,
Pratik Patel

Hi @msghaderi77 ,

   <downloadExcel :leading_zero="true" class="btn btn-default"
                   :data="json_data" type="xlsx"
                   worksheet="My Worksheet" :fields="json_fields"
                   name="filename.xlsx">
    </downloadExcel>

Try xlsx it will work.

Thanks,
Pratik Patel

Hi @msghaderi77 ,

   <downloadExcel :leading_zero="true" class="btn btn-default"
                   :data="json_data" type="xlsx"
                   worksheet="My Worksheet" :fields="json_fields"
                   name="filename.xlsx">
    </downloadExcel>

Try xlsx it will work.

Thanks, Pratik Patel

this one does not work.
Excel will give me an error that the file format or file extension is not valid!!!!

Hi @msghaderi77 ,

   <downloadExcel :leading_zero="true" class="btn btn-default"
                   :data="json_data" type="xlsx"
                   worksheet="My Worksheet" :fields="json_fields"
                   name="filename.xlsx">
    </downloadExcel>

Try xlsx it will work.
Thanks, Pratik Patel

this one does not work. Excel will give me an error that the file format or file extension is not valid!!!!

It's available in new version.

Please update it to latest version.

1.0.15

Great.😍
It's working.