1

I have following data -

{billDate: "21-1-2021", createdDate: "20-2-2021", modifiedDate: "20-2-2022"}
...
]

I have converted date string to date js objects.

While exporting to sheet using method XLSX.utils.json_to_sheet How can i specify different dateNF for diffrent columns.

For example for billDate i need - dd-mm-yyyy but for other two dates i need output as mm-dd-yyyy.

So far i have tried following two ways

// 1 column config 
// OUTPUT: has no impact of dateNF
XLSX.utils.json_to_sheet(data, {
columns: [{
  name: "billDate",
  key: "billDate",
  dateNF: "dd-mm-yyyy"
},
{
  name: "createdDate",
  key: "createdDate",
  dateNF: "mm-dd-yyyy"
}]
});


// 2 above configuration with header property
// OUTPUT: Adds 3 columns with data "[object Object]" for 3 columns then after 3 columns adds original data
XLSX.utils.json_to_sheet(data, {
  header: [{
   name: "billDate",
   key: "billDate",
   dateNF: "dd-mm-yyyy"
  },{
    name: "createdDate",
    key: "createdDate",
    dateNF: "mm-dd-yyyy"
  }]
});

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.